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

Can anyone help me understand why my code is not working? I’m literally following the guy step by step on youtube and somehow my code isn’t working…

Was anyone able to do this exercise without following the guy on youtube? I feel like this goes from spoon feeding to throwing you in the pit and I’m extremely frustrated.

const input = ‘Yaaas I hate coding’;

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

let recultArray = ;

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

// console.log("inputIndex = " + input[inputIndex]);

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

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

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


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


  } else {







Gotta love typographical errors.