I don't understand.What is wrong with this code?


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661#

Oops, try again. It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.


/*jshint multistr:true */

var text = "Hello my name is Jack. Nice to meet you?";

var myName = "Jack";

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]);
      }
     
       }
  
 
}


I don't understand why this doesn't work please help!


#2

here:

or (var i = 0; i < text.length; i++);

the semi-colon after i++) will interrupt the loop. remove the semi-colon


#3

Thanks man.Huge help.


#4