[SOLVED] Whale talk

ok so i have to solve the whale talk exercise and the code seems right to me (im probably wrong), but when i try to run it, the result is an error.

here is the code

let input = 'Hello World';

let vowel = ['a', 'e', 'i', 'o', 'u'];

let resultArray =[];

for (x=o; x< input.length; x++){

  for (y=o; y<vowel.length; y++){

    if (input[x] === vowel [y]){

      if (input[x]) === "e" {

        resultArray.push ('ee')

      }else if (input[x] === "u"){

        resultArray.push ('uu')

      }else { resultArray.push (input[x])

      }

    }

  }

}

console.log (resultArray.join('').toUppperCase())

Things I notice:

x=o and y=o

These are counters, so the values should start with 0, besides that they have not yet been defined so they should be let x = 0 and let y = 0.

if (input[x]) === "e" {

Will definitely give an error, the comparison should be between the brackets.

if (input[x] === "e") {

Last but not least

console.log (resultArray.join(ā€™ā€™).toUppperCase())

Too many 'pā€™s in toUppperCase()

console.log (resultArray.join(ā€™ā€™).toUpperCase())

Happy coding!

2 Likes

thanks a lot!! it works!

1 Like