Whale Talk Please Help!

const input = ‘Free Willy the whale’;

const vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’];

let resultArray = ;

for (let inputIndex = 0; inputIndex < input.length; inputIndex++) {

//console.log("The input index is = " + input[inputIndex]); Prints the input as letters

for(let vowel = 0; vowel < vowels.length; vowel++) {

//console.log('The vowel = ' + vowel); Prints the amount of vowels 0-4

if (input[inputIndex] === vowel[vowels]){

  if(input[inputIndex] === 'e') {

    resultArray.push('ee');

  } else if (input[inputIndex] === 'u') {

    resultArray.push('uu');

  

  } else{

resultArray.push(input[inputIndex]);

  

  }

}

};

}

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

For some reason whenever I try to log my code, logs the resultArray as undefined. I have tried searching through the internet to see if someone has ran into the same problem but I have had no luck.

Hello @core0829630930, welcome to the forums! It seems you’ve got these two the wrong way around:

if (input[inputIndex] === vowel[vowels]){
                          ^^^   ^^^^^^
                          /        \
     this should be "vowels"     this should be "vowel"
2 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.