Stuck on the Whale Talk Project

Hey Everyone!

First time posting with an issue. I’ve been working through the coding on the Whale Talk project and am stuck in while outputting the content from the first if statement inside of the nested loop where I’m comparing the string to the vowels. I’m not getting any errors in the console when I try to log the output but I’m also not seeing any content logged.
You can view the Gist for my current code here. I have also pasted it below for reference.

let input = 'for whom the bell tolls'; const vowels = ['a','e','i','o','u']; let resultArray = []; for (let i = 0; i < vowels.length; i++){ //console.log(vowels[i]); for (let v = 0; v < vowels[i].length; v++){ if(input[i] === vowels[v]){ console.log(input[i]); } } };

Where am I going wrong? This is step 8 that I’m stuck on:

Inside the second for loop, write a code block that compares the input letter to every letter in the vowels array.

Note: To check that everything is working properly, log letter matches to the console.

Thank you in advance!

you want to loop through each letter in the input string, so this is not correct:

let i = 0; i < vowels.length; i++

because it runs just five times.
Then, for each letter in the input string, you want to loop through each letter in the vowels array, so this is also not correct:

let v = 0; v < vowels[i].length; v++

vowels[i].length is 1.

Thank you! Don’t know how I missed that I was working in the vowels rather than the input for the first one. After seeing that I was able to also correct the second issue you pointed out. Think I’m on the right path now as I’m seeing [ 'o', 'o', 'e', 'e', 'o' ] in the console now.

1 Like