curriculum/challenges/english/blocks/daily-coding-challenges-javascript/68adce01c0e1144d0a902956.md
Given a string, return a new version of the string where each vowel is duplicated one more time than the previous vowel you encountered. For instance, the first vowel in the sentence should remain unchanged. The second vowel should appear twice in a row. The third vowel should appear three times in a row, and so on.
a, e, i, o, and u, in either uppercase or lowercase, are considered vowels.repeatVowels("hello world") should return "helloo wooorld".
assert.equal(repeatVowels("hello world"), "helloo wooorld");
repeatVowels("freeCodeCamp") should return "freeeCooodeeeeCaaaaamp".
assert.equal(repeatVowels("freeCodeCamp"), "freeeCooodeeeeCaaaaamp");
repeatVowels("AEIOU") should return "AEeIiiOoooUuuuu".
assert.equal(repeatVowels("AEIOU"), "AEeIiiOoooUuuuu");
repeatVowels("I like eating ice cream in Iceland") should return "I liikeee eeeeaaaaatiiiiiing iiiiiiiceeeeeeee creeeeeeeeeaaaaaaaaaam iiiiiiiiiiin Iiiiiiiiiiiiceeeeeeeeeeeeelaaaaaaaaaaaaaand".
assert.equal(repeatVowels("I like eating ice cream in Iceland"), "I liikeee eeeeaaaaatiiiiiing iiiiiiiceeeeeeee creeeeeeeeeaaaaaaaaaam iiiiiiiiiiin Iiiiiiiiiiiiceeeeeeeeeeeeelaaaaaaaaaaaaaand");
function repeatVowels(str) {
return str;
}
function repeatVowels(str) {
const vowels = "aeiouAEIOU";
let count = 0;
let result = "";
for (let char of str) {
result += char;
if (vowels.includes(char)) {
result += char.repeat(count).toLowerCase();
count++;
}
}
return result;
}