Weird result in "6. Log it"


#1

/*jshint multistr:true */

var text = "Hi my name is Jacob, Jacob is my name";
var myName = "Jacob";
var hits = [];
for(var i = 0; i < text.length; i++) {
if (text[i] === 'J');{
for (var j = i; j < (myName.length + i); j++) {
hits.push(text[j])

 }
 }

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

this is my code, and when i run it i do get to the next step, but in the console it shows random letters from my sentence, and it says a couple of times "undefined" i have really no clue to why it does this.
plz help :sweat_smile:


#2

Hi try to remove the ";" after this if statement .........if (text[i] === 'J');


#3

Thanks a lot dude! it worked :smiley: