Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (user){
- let username = user[0];
- let password = '';
- for (let i = username.length - 1; i >=0; i--){
- password +=username[i];
- }
- let counter = 1;
- for (let i = 1; i <= user.length - 1; i++, counter++){
- let currentUsername = user[i];
- // Сравняваме елемента на позиция i с паролата
- if (currentUsername === password){
- console.log(`User ${username} logged in.`);
- break;
- }
- if (counter === 4){
- console.log(`User ${username} blocked!`);
- }else {
- console.log(`Incorrect password. Try again.`);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement