hi all,
I’m trying to create this exercise called whale talks where only the vowels of a word is copied, and in case it is a ‘e’ or ‘u’, these two vowels are repeated.
For example: the word turtle would be : uuee;
this is my code so far:
function whaleTalks(word) {
let whaleWord = [...word];
let whaleWordArray = [];
for (let letter of whaleWord) {
if (letter === 'u') whaleWordArray.push(letter + 'u');
if (letter === 'e') whaleWordArray.push(letter + 'e');
if (letter === 'a' || 'i' || 'o') whaleWordArray.push(letter);
}
return whaleWordArray
}
console.log(whaleTalks('turtle'))
Even a nested for loop didn’t work.
Whenever I get to the last condition, that if statement push all the letter from the word into the empty array, not just the vowels. Thanks