Whale talk: is my output right?

https://www.codecademy.com/courses/introduction-to-javascript/projects/whale-talk

Is this the right output of my code?
EEEEEEOO

const input = 'Hello world!';
const vowels = ['a', 'e', 'i', 'o', 'u'];
let resultArray = [];

for (let i = 0; i < input.length; i++) {
  //console.log('i is '+ i);
  {
  for (let j = 0; j < vowels.length; j++)
  //console.log('j is ' + j);
    {
      if (input[i] === vowels[j]) {
        resultArray.push(input[i])
      }
      {
        if (input[i] === 'e'){
          resultArray.push(input[i]);
        } {
          if (input[i] === 'u') {
            resultArray.push(input[i])
          }
        }
      }
    }
  }
}

console.log(resultArray.join('').toUpperCase());

No, it should be:

EEOO

E is long, so should be doubled, and there are two O's in hello world. Resulting in EEOO

4 Likes

Thank you! But what is wrong with my code then?

i would start with removing all the redundant curly brackets ({}), you have loads of them.

you have 2 loop and 3 conditions, which mean you should have 10 curly brackets (5 opening, 5 closing). I count 16.

then go through the flow of your program.

Thank you, that worked!