Https://www.codecademy.com/courses/introduction-to-javascript/projects/whale-talk

Hello Codecademy Community! Quick Question, my console is saying that v is not defined. In my nested for loop I clearly state that v = 0; so why is it saying that it is not defined?


Error Message:

Output:
The Index Input is 0
/home/ccuser/workspace/learn-javascript-loops-P1/main.js:11
if (input[i] === vowels[v]){
^

ReferenceError: v is not defined

const input = "andrew";

const vowels = ["a", "e", "i", "o", "u"]

resultArray = []; 

for (let i = 0; i < input.length; i++ ) {
  console.log( `The Index Input is ${[i]}`)

 for (let v = 0; v < vowels.length; v++); {
   if (input[i] === vowels[v]){
     console.log( 'the ')
  }
  }
}

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

Hello,

just a quick observation: i see missing semi-colons in places, and extra semi-colons where there shouldn’t be any.

Whilst missing ones aren’t necessarily always problematic, semi-colons in places where there shouldn’t be any definitely is ; )

2 Likes