Advertisement
Todorov_Stanimir

09. Password Generator

Jul 19th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function passwordGenerator(input) {
  2.     let output = input[0].concat(input[1]).split('');
  3.     let code = input[2].toUpperCase().split('');
  4.     let indexOfCode = 0;
  5.     for (index in output) {
  6.         let vowel = output[index].toLowerCase();
  7.         if (vowel === 'a' || vowel === 'e' || vowel === 'i' || vowel === 'o' || vowel === 'u') {
  8.             output[index] = code[indexOfCode];
  9.             if (indexOfCode === (code.length - 1)) {
  10.                 indexOfCode = 0;
  11.             } else {
  12.                 indexOfCode++;
  13.             }
  14.         }
  15.     }
  16.     output = output.reverse().join('');
  17.     console.log(`Your generated password is ${output}`);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement