4. Your "if' statement


Here's my code. Anyone know why it isn't working? error is reading ReferenceError: Li is not defined

var text =("Lisa", "Mark", "Louise", "Lisa", "Tammy", "Lisa");
var myName="Lisa";
var hits =[];
for (i=0; i>=text.length; i++);
if (i>=2);


The error message is the best help. It says "Li is not defined". You meant to type i but typed Li instead. Understanding the error message is your first help for any problem.

However, the code has other syntax errors. Your first curly brace should be at the end of the fifth line. The loop should end when it has gone through all the elements of the array. The if statement checks whether the current letter is the same as the first letter of your name. You don't need to add console.log yet because the instruction hasn't asked for it yet here.

Also, you can click on the hint button. It gives you hints on the syntax.


var text = ("Lisa", "Mark", "Louise", "Lisa", "Tammy", "Lisa");
var myName = "Lisa";
var hits = [];

for (i = 0; i > text.length; i++) { 
  if (text[i] === "L") { 


just left to fix the var text:

var text = ("Lisa, Mark, Louise, Lisa, Tammy, Lisa");

because a variable can store just 1 value if you want to store more that 1 value you have to use array.