JavaScript Whale Talk - 'E' and 'U' don't double

I’ve managed to find most of my mistakes, but I’m unable to figure out what I’m doing wrong with the output. I’ve checked my code line by line with the video walkthrough and I can’t see any discrepancy.

let input = ‘turpentine and turtles’;
const vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’];
let resultArray = ;

for (let inputIndex = 0; inputIndex < input.length; inputIndex++){
for (let vowel = 0; vowel < vowels.length; vowel++){
if (input[inputIndex] === vowels[vowel]){
if (inputIndex[inputIndex] === ‘e’){
resultArray.push(‘ee’);
} else if (inputIndex[inputIndex] === ‘u’){
resultArray.push(‘uu’);
} else {
resultArray.push(input[inputIndex]);
}
}
}
}
console.log(resultArray.join(’’).toUpperCase());

Any help would be greatly appreciated.

Hello @forisa , welcome to the forums! Check your nested if and else if statements:

and

Should you be using inputIndex[inputIndex]? What would this result in?


For future reference, please format code according to this guide.

Thank you. A 45th closer look and your kind words made it click. And I will be checking out the format code information. My apologies.

1 Like