Codecademy Forums

Whale Talk

Hello Somebody could help me. Whats wrong with my code? It doesn’t print, the webbrowers crashes.

let input = 'wie ben jij';

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

let resultArray= [];

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

this usually indicates an infinity loop. Which is also the case here:

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

this loop will never end, you see it? If you don’t, that is okay, just say so and you will get another hint

4 Likes