" your second for loop "


#1



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


error : 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.


Replace this line with your code. 

ar text = " hii my name is jatin alpha beta gamma jatin pujama " ;
var myName = "jatin";
var hits = [];

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


#2

@jatinpunia,

The condition in your 2nd FOR-loop should be

j <  i+myName.length

#3
> var text = "Hey, how are you \
> doing? My name is thuc.";

> var myName="thuc";

> var hits=[];

> for(var i=0; i<text.length; i++){
>     if(text[i]==='t'){
>         for(var j=i; j<i+myName.length;j++){
>             hits.push(text[j]);
>         }
>     }
> }
> console.log(hits.valueOf());

#4

var text="Nikos Nikos";
var myName="Nikos";
var hits=[];

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

if("o"===text[i]) {

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

}
this worked for me