Advertisement
Spocoman

02. Password

Dec 26th, 2021 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Password(input) {
  2.     let user = input[0];
  3.     let pass = input[1];
  4.     let index = 2;
  5.  
  6.     while (input[index++] !== pass){
  7.     }
  8.  
  9.     console.log(`Welcome ${user}!`);
  10. }
  11.  
  12. Решение с фор цикъл:
  13.  
  14. function password(input) {
  15.     let user = input[0];
  16.     let pass = input[1];
  17.  
  18.     for (let i = 2; i <= Number.MAX_VALUE; i++) {
  19.         if (pass === input[i]) {
  20.             console.log(`Welcome ${user}!`);
  21.             return;
  22.         }
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement