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