Advertisement
Liliana797979

while loop leccii

Jan 5th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function password(input) {
  2.     let username = input[0];
  3.     let password = input[1];
  4.     let data = input[2];
  5.     let index = 3;
  6.  
  7.     while(data !== password) {
  8.         data = input[index];
  9.         index++;
  10.     }
  11.     console.log(`Welcome ${username}!`);
  12. }
  13.  
  14. function sequence([arg1]) {
  15.     let n = parseInt(arg1);
  16.     let num = 1;
  17.  
  18.     while(num <= n) {
  19.         console.log(num);
  20.         num = 2 * num + 1;
  21.     }
  22. }
  23.  
  24.  
  25. function numberInRange(args) {
  26.     let i = 0;
  27.     let num = parseInt(args[i]);
  28.     while(num < 1 || num > 100) {
  29.         i++;
  30.         console.log(`Invalid number!`);
  31.         num = parseInt(args[i]);
  32.     }
  33.     console.log(`The number is: ${num}`);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement