Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function login(arr){
- let username = arr[0];
- let password = "";
- for (let i = username.lenght - 1; i >= 0; i--){
- password += username[i];
- }
- let counter = 1;
- for (let i = 1; i <= arr.lenght - 1; i++, counter++){
- let currentUsername = arr[i];
- if (counter === 4){
- console.log(`User ${username} blocked!`);
- break;
- }
- if(password === currentUsername){
- console.log(`User ${username} logged in.`);
- break;
- } else{
- console.log("Incorrect password. Try again!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement