Your Second "For" Loop isn't working


My code gives me the error 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." I have been trying to fix this for a while, I have looked at several discussion pages, and nothing works.

/*jshint multistr:true */
var text = "Jonah Jonah Jonah I'm not even trying to Jonah make an actual sentence Jonah Jonah";

var myName = "Jonah";
var hits = [];

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


I actually looked at this to help me.


Help you with what?
And I don't really think this code would help. There's something wrong with it.


Hi this line

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

you should change the var i = text[0] with just var i = 0 .. Because with the text[0] it set the variable i to the first letter of the variable text but you should put it equal to 0


Thanks so much! It works fine now!



for ([initialization]; [condition]; [final-expression]) {

In the Initialization of the 1st FOR loop
you should use
var i = 0;
instead of you i = text[0] which corresponds to the first-letter of the text which will be a "J"