5. Your second "for" loop


5 - your second "for" loop

I've looked at a few of the other posts and can't figure out where i'm going wrong. I've tried various different uses of curly braces and terminations. Not sure where and what went wrong.
Error: 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 = "I like java script it's a pretty cool language.";

var myName = "Joe";

var hits = [];

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


Why are you doing < i + myName.length? Its just suppose to be myName.length since its the length.

Why are you pushing i? Your suppose to push j to it.. I mean that was the reason we did the second for loop right? :confused: ... Anways Hope this helped @solium24


First, put your name inside the value for var text.
The point of your final Code is to Extract your name from within other text :wink: