Whale Talk/ Loops

Hello, Could somebody please help me figure out what I am doing wrong in the whale talk excersise in the javascript section.I followed the expert video, and went over every detail i thought. But when I run the code only the first vowel of the string pops up, instead of all the vowels and doubled E’s and U’s. Here is my code,

const input = 'I am Jesse the whale';
const vowels = ['A', 'E', 'I', 'O', 'U'];
let resultArray = [];
for (let inputI = 0; inputI < input.length; inputI++) {
  for (let vowelsI = 0; vowelsI < vowels.length; vowelsI++) {
  if (input[inputI] === vowels[vowelsI]) {
    if (input[inputI] === 'E') {
    } else if (input[inputI] === 'U') {
    } else {


Please and thank you.

1 Like

The only letter that matches to your vowels array is the uppercase “I”. All the rest are lowercase so do not return a match for those vowels.

This will fix that…

const input = 'I am Jesse the whale'.toUpperCase();

// ["I", "A", "EE", "EE", "EE", "A", "EE"]

If you don’t want to modify the input table, you could use toLowerCase() on your If condition, like this :

if (  (input[inputI]).toLowerCase() === vowels[vowelsI].toLowerCase())

By doing this way, you don’t have to modify the push() part


I can’t believe I overlooked that. Thanks for the help!!!

1 Like