Log it!


#1

I don't know what is going on but my code keeps printing out "Your name wasn't found!" here is my code:
/*jshint multistr:true */

var text = "Nathan is nice and his name \ is Lee do you know where Nathan is?";
var myName = "Nathan";
var hits = [];

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

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

Can anyone help?


#2

Remember, you need semi colons after the console.logs. :smiley:


#3

Thanks but that doesn't really help my problem.


#4

Okay.... Look at this now:

You see, you need brackets after the if statement.

Also, at the end, you're supposed to see if the hits.length is equal to 0. Not:


#5

Thanks it worked wonders!