Your Second for loop


#1

I really don't know what's wrong with this code. I'm kind of stuck.
I keep getting this error sayin

"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."


var text = "Hey how are you doing? \
            My name is Kate.";

var myName = "Kate";

var hits = [];

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


#2

the problem is actually in your first for loop

the first for loop condition is false (from the beginning) so your first loop never runs


#3

there,

i > text.length ?


#4

thanks for that, I totally missed that. Cause it let me pass through my first loop. Thanks for the fast reply :slight_smile:


#5

Thanks for that, Totally missed that.


#6

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