7/7 Pass but not sure


#1

I pass it but , only show up this [ ]
doesn't show my name is it correct ?

var text = " Eric blah blah blah blah john blah blah Eric blah blah " ;
var myName = "Eric" ;
var hits = [ ] ;

for (i = 0; i < text.length ; i++ ){
if(text[i] === 'E')
{
for(var E = i ; E < (i + myName.length);E++){
hits.push(text[E]);
}
}
}

if(hits.length = 0)
{
 console.log("Your name wasn't found !");   
}
else
{
console.log(hits);        
}

#2

Hi here

if(hits.length = 0)

You should put === instead of =


#3

if(hits.length = 0) ASSIGNS 0 TO hits.length (theoretically) ONE =sign is an assignment operator.

for comparison, you need 2 or 3 = signs (== , or ===) . If you are still confused, you can go back and read operators again...


#4

yes is correct :slightly_smiling: thanks you !!


#5

thanks you i am more understand now ^^