# Stuck on Whale Talk exercise

Hello!

I can’t understand why this code isn’t working properly!

The output is “UUEEEEUUEE” but it should be “UUEEIEEAUUEE”.

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

for (let i = 0; i < input.length; i++) {
for (let j = 0; j < vowels.length; j++) {
if (input[i] === vowels[j]){
if (input[i] === “e”) {
resultArray.push(“ee”);
}
if (input[i] === “u”) {
resultArray.push(“uu”);
}
}
}
}

console.log(resultArray.join(‘’).toUpperCase());

You code make double, but don’t push single letters into your new array.

I didn’t quite understand what you mean.

I think what you want to do is the following:

If(letter == e) → resultArray.push(“ee”)
elif(letter == u) → resultArray.push(“uu”)
else → resultArray.push(letter)

You forget push single letter in your condition.

I see!

I edited the code and now it also shows A and I, but it also has more E’s and U’s.
The output is now “UUEEEIEEEAUUEEE”, instead of “UUEEEEUUEE”, but it’s still not “UUEEIEEAUUEE”.

Can you set the conditions of the problem?

Honestly I don’t know how I could do that besides copying and pasting all tasks, is that okay?

1 Like

Ok… I think the mistake in 10 steep.

for (i = 0; i < input.length; i++) { if (input[i] === 'e') { resultArray.push("e") } else if(input[i] === 'u'){ resultArray.push("u") } for (j = 0; j < vowels.length; j++) { if (input[i] === vowels[j]) { resultArray.push(vowels[j]) } } }

You need make outside second loop if - condition for ‘e’ and ‘u’.

In you code – ‘e’ and ‘u’ – have double – and you can 3 ‘E’.

1 Like

Ohhh, thanks for that! I guess checking things a lot of times is necessary for a programmer.

Yes, you very right.
But, if you stuck on many time, best you can make – it ask other to help you. Before ask you can try semself, see on google, see on wiki, see on other site and documentation.

And the most important thing is to understand the condition of the problem. If you understand what they want from you - this is more than half the solution.

Good luck and take fun.

You need make outside second loop if - condition for ‘e’ and ‘u’.

In you code – ‘e’ and ‘u’ – have double – and you can 3 ‘E’.

Hmm… I’m test my code.

Hey,

I looks like you are loving programming and getting more interest in it. As you are facing issue in loop combination and not getting the required outputs. I think you should visit https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-loops here you can understand basics of Loop and learn many more programming things.

I’m also stuck on this and your answers doesn’t even solve my problem.