Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function passwordGenerator(input) {
- let text = input[0].concat(input[1]);
- let matches = text.match(/[aeiou]/gi);
- let string = input[2].toUpperCase();
- let arrayForReplace = string.repeat(Math.ceil(text.length / string.length));
- arrayForReplace = arrayForReplace.substr(0, matches.length).split('');
- let pattern = /[aeiou]/gi;
- text = text.replace(pattern, '*');
- for (let letter of text) {
- if (letter === '*') {
- text = text.replace(letter, arrayForReplace[0]);
- arrayForReplace.shift();
- }
- }
- let password = text.split('').reverse().join('');
- console.log(`Your generated password is ${password}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement