Help with my javaScript "Whale Talk" project


I’m a beginner with JS and i’ve been logging this code but i seem to be getting a syntax error and i don’t know where it went wrong :

const input = ‘I love Whale Talk.’;

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

let resultArray = ;

for (let inputIndex = 0; inputIndex < input.length; inputIndex++;) {
for (let vowelIndex = 0; vowelIndex < vowels.length; vowelIndex++;) {
if (input[inputIndex] === vowels[vowelIndex]) {
if (input[inputIndex] === ‘e’ || input[inputIndex] === ‘u’) {


This is the link ???


Suggestion: each time you post a question, paste in the URL to the lesson. This allows us to go back and look at the entire lesson objective.


Thanks, I’ve added it


Hello, I 've noticed that firts you must make sure that the letters in the string are not capital letters by using this piece of code right below 'const input ':

input = input.toLowerCase();

What is more you’ve got a bug after ‘if statement’:
you push the result to the const resultArray = (you don’t have the returnArray) :slight_smile: so instead of this:


try this:


Let me know if this works :slight_smile:


Thanks for your help, but i’m still getting syntax error.


Ok, I have also noticed that ‘const input’ should be changed to ‘let input’ (you change it to lowerCase later on)
Also - no need for the semicolon at the end of for loop

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

shoul be

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

also here:

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

should be

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

if you want to console log the final whale message you should console log this:


Let me know if that works :slight_smile:


Extra Study

Ignore this post for the time being, only bookmark it and return when you reach the unit on iterators.

input = "You Are All Wee Gillis";
vowels = ['a','e','i','o','u'];
whaleTalk = [];
input.split('').filter(v => vowels.includes(v.toLowerCase())).forEach(x => {
  if (x === 'e' || x === 'u') {
    whaleTalk.push((x + x));
  } else {
console.log(whaleTalk.join('').toUpperCase())    //  OUUAEEAEEEEII

Don’t try to make sense of it, just now. You can see where our learning about the for loop (which is an iterator, in fact) will eventually lead.


Thank you, it works.


Super! :slight_smile: Good luck!


2 posts were split to a new topic: Coul you take a look at my code bellow?