Stuck on second 'for' loop


#1


I'm stuck at the second "for" loop portion of the "Search Text for Your Name" exercise. In addition to reading a bunch of other helpful answers on here, I've also tried troubleshooting this a half-dozen ways. I keep getting the "It looks like your second 'for' loop isn't pushing values to the hits array" error message.

Help?


/*jshint multistr:true */

var text = ["Years later, as he faced the firing squad, \
Shane would remember that distant Saturday when his father \
took him to discover ice."];

var myName = ("Shane");

var hits = [];

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

console.log(hits);


#2

text is an array in your case, see what this does to your first loop:

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

your loop makes only one iteration, which makes sense given there is one item in your array


#3

Ahhh. Got it. thanks!


#4