Advertisement
Lulunga

Text Processing 09. Password Generator

Jul 19th, 2019
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function passwordGenerator(input) {
  2.  
  3.     let text = input[0].concat(input[1]);
  4.     let matches = text.match(/[aeiou]/gi);
  5.  
  6.     let string = input[2].toUpperCase();
  7.     let arrayForReplace = string.repeat(Math.ceil(text.length / string.length));
  8.     arrayForReplace = arrayForReplace.substr(0, matches.length).split('');
  9.     let pattern = /[aeiou]/gi;
  10.     text = text.replace(pattern, '*');
  11.  
  12.     for (let letter of text) {
  13.         if (letter === '*') {
  14.             text = text.replace(letter, arrayForReplace[0]);
  15.             arrayForReplace.shift();
  16.         }
  17.     }
  18.     let password = text.split('').reverse().join('');
  19.  
  20.     console.log(`Your generated password is ${password}`);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement