-
-
Save lumie31/57deb8ef6dfa0b5d9f4d77cde91efbc3 to your computer and use it in GitHub Desktop.
Create a loooong teeeext generator that takes in a string and an integer n, and multiplies the vowels in the string by n.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const longText = (str, num) => { | |
if (typeof str !== 'string') return 'Input must be a valid string' | |
let newStr = '' | |
const vowels = ['a', 'e', 'i', 'o', 'u'] | |
for (let char of str) { | |
if (vowels.includes(char)) { | |
newStr += char.repeat(num) | |
} else { | |
newStr += char | |
} | |
} | |
return newStr | |
} | |
// $longText('hello world', 3) --> heeellooo wooorld |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment