My second "for" loop


#1

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


I get this message, I am not sure what is wrong: 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 people, my name is Shaun. Shaun will be creating a programme that searches for the name Shaun.";
var myName= "Shaun"
var hits= []

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


#2

the problem is in the first for loop:

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

a loop will run for as long as the condition is true. In the first run of the loop, i is zero, which is not greater then text.length, so the loop will never execute

change the condition of the loop


#3

Thanks for your speedy response, I have moved onto the next exercise. thanks for your help


#4