Second FOR loop


Search Text for Your Name, #5.

I have been reading this form and I can not get this freaking code to work still. Before it was crashing my web browser over and over again and i added the === to my code and at least it isnt doing that now. without that my code just crashes. I'm getting this message

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="blah blah blah Sam is blah blah / pine apple apple pineapple Sam";

var myName = "Sam";

var hits = [];

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


your first for loop:

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

this condition will be false from the start, the first loop will never run, nothing will be pushed into your hits array.

maybe change the condition of this loop?


Thank you it worked. I thought i had that before and it was crashing so I'm not really sure now what i changed before lol


Yeah I had the same problem when I went through this lesson long ago. Those infinite loops can be a challenge!