Advertisement
Guest User

Untitled

a guest
May 25th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function login(input) {
  2. let username = input.shift();
  3. let password = input.shift();
  4. let output = "";
  5. let counter = 0;
  6.  
  7. for (let j = 1; j <= 4; j++) {
  8. for (let i = username.length - 1; i >= 0; i--) {
  9. a = username.charCodeAt(i);
  10. output += `${String.fromCharCode(a)}`;
  11. output = output.trim();
  12. }
  13. if (password != output && counter<3) {
  14. console.log("Incorrect password. Try again.");
  15.  
  16. } else if (password == output) {
  17. console.log(`User ${username} logged in.`);
  18. break;
  19. }
  20. if (counter == 3) {
  21. console.log(`User ${username} blocked!`);
  22. break;
  23. }
  24. counter++;
  25. output = "";
  26. password = input.shift();
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement