Todorov_Stanimir

Basic Syntax, Cond.Stat. and Loops-Exerc.,problem 09.Login

May 17th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function login(input) {
  2.     let user = String(input.shift());
  3.     let password = '';
  4.     for (let i = user.length; i >= 0; i--) {
  5.         password += user.charAt(i);
  6.     }
  7.     let checkingpassword = '';
  8.     for (let y = 1; y <= 4; y++) {
  9.         checkingpassword = String(input.shift());
  10.         if (checkingpassword == password) {
  11.             console.log(`User ${user} logged in.`);
  12.             break;
  13.         } else {
  14.             if (y != 4) {
  15.                 console.log('Incorrect password. Try again.');
  16.             } else {
  17.                 console.log(`User ${user} blocked!`);
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment