Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- const strForPass = args[0].concat(args[1]);
- const charsForNewPass = args[2].split('');
- const arrOfChars = strForPass.toLowerCase().split('');
- const findVowels = (str) => str.match(/[aeiou]/ig);
- let countVowels = 0;
- arrOfChars.forEach((ch, index) => {
- if (findVowels(ch)) {
- if (countVowels >= charsForNewPass.length) {
- countVowels = 0;
- }
- if (charsForNewPass[countVowels] !== undefined) {
- arrOfChars.splice(index, 1, charsForNewPass[countVowels].toUpperCase());
- }
- countVowels += 1;
- }
- });
- console.log(`Your generated password is ${arrOfChars.reverse().join('')}`);
- }
Add Comment
Please, Sign In to add comment