6/7 Cannot figure out why my name is not printing


#1

Here is my code:

/*jshint multistr:true */
var text = "My name is Jennifer";
var myName = "Jennifer";
var hits = [];
for(var i=0; i< text.length; i++){
if(text[i] ==='J'){
for(var j=i; j < (i+myName.length);j++){
hits.push(text[j])

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

This prints out "Your name wasn't found!" and I pass. But shouldn't it print my name? I have searched and searched but I can't figure out what is wrong. I took out the semi colon ; after myName.length); but then I receive a syntax error. Can anyone else see what my mistake is??


#2
if("hits.length === 0") {

Expected expression but instead saw a string primitive.

if(hits.length === 0) {

#3

Thank you! Got it! Figuring out that quotes go around strings, not expressions.