Second for loop


#1

I seem to be stuck on this one I've checked other topics on the same lesson and im still stuck

var text= "Kyle is the all time greatest human being ever. If only more people could aspire to be what Kyle is.";
var myName = "Kyle";
var hits =[]
for( var i=0; i > text.length; i++){
if(text[i] === 'K'){
for (var j = i; j < (i+myName.length); j++){
hits.push(text[j]);

    }
}

}

It keeps telling me "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." myName is used in the text a couple times but i still dont know the issue any help would be greatly appreciated

`


#2

Read my comment

var text= "Kyle is the all time greatest human being ever. If only more people could aspire to be what Kyle is.";
var myName = "Kyle";
var hits =[];

for( var i=0; i > text.length; i++){  // A for loop repeats until a specified condition evaluates to false. Is i greater than text.length ???
        if(text[i] === 'K'){
              for (var j = i; j < (i+myName.length); j++){
                   hits.push(text[j]);
              }
         }
}

#3

.< i knew it was something small like that


#4

I thank you bunches kind sir


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.