The code is right but there is no output


#1

Can someone please help me with it? My code is:

/*jshint multistr:true */
var text = "blah blah Emily blah blah blah \
blah blah Emily blah blah blah blah \
Emily blah blah blah?";
var myName = "Emily";
var hits = [];
for (var i=0; i < text.length; i++){
if (text[i] === 'E'){
for (var j=i; j < i + myName.length; j++){
hits.push(text[j]);
}
}
};
if (hits.length = 0){
console.log("You're name wasn't found");
} else{
console.log(hits);
}

The code runs but the console shows just [] - why?


#2

Hi in your last if statement

if (hits.length = 0)

instead of = put ===


#3

It works, thanks so much :slightly_smiling: