Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function login(input) {
- let usrnm = input[0];
- let index = 1;
- let password = input[index++];
- let newString = "";
- let enterCounter = 0;
- for (let i = usrnm.length - 1; i >= 0; i--) {
- newString += usrnm[i];
- }
- while (newString !== password && enterCounter < 3) {
- enterCounter++;
- console.log("Incorrect password. Try again.");
- password = input[index++];
- }
- if (newString === password) {
- console.log(`User ${usrnm} logged in.`);
- } else {
- console.log(`User ${usrnm} blocked!`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement