Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function login(input) {
- let userName = input.shift();
- // console.log(userName);
- let password = userName.split('').reverse().join("");
- // console.log(password);
- let passCounter = 0;
- let currentPassword = input.shift();
- while (currentPassword !== password && passCounter <= input.length+1) {
- passCounter++;
- console.log(`Incorrect password. Try again.`);
- currentPassword = input.shift();
- }
- if (currentPassword === password) {
- console.log(`User ${userName} logged in.`);
- } else {
- console.log(`User ${userName} blocked!`);
- }
- }
- login(['sunny','rainy','cloudy','sunny','not sunny']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement