Hello! I keep getting every letter returned to me in the console instead of just the “e” and “u”. Here is my code. Any help on this I would greatly appreciate as I have been at this for two hours now.
const input = “turpentine and turtles”;
const vowels = [“a”, “e”, “i”, “o”, “u”];
const resultArray = ;
for (let i = 0; i < input.length; i++) { //console.log(i);
if (input[i] === “e”) {
resultArray.push(input[i]);
}
if (input[i] === “u”);
{
resultArray.push(input[i]);
}
for (let j = 0; j < vowels.length; j++) { //console.log(j);
if (input[i] === vowels[j]) { //console.log(input[i]);
resultArray.push(input[i]);
}
}
}
Hi Kirativewd thank you so much for that. I took it out but now the code is logging
[
‘u’, ‘u’, ‘e’, ‘e’,
‘i’, ‘e’, ‘e’, ‘a’,
‘u’, ‘u’, ‘e’, ‘e’
]
I am trying to understand why the ‘i’'s and ‘a’'s are being printed out. Any clarification on this?
Take a phrase like ‘turpentine and turtles’ and translate it into its “whale talk” equivalent: ‘UUEEIEEAUUEE’
"a", "i" and "o" are also vowels (have a look at the vowels array in your code).
"u" and "e" are supposed to be doubled, whereas the remaining vowels aren’t to be doubled but are still to be included in the result. Only the consonants are ignored.