Help on 5/9


#1

Here's my code, what did I mess up/do wrong on?

/*jshint multistr:true */
var text = "Jason! Jason! Jason!"
var myName = "Jason"
var hits = []

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

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


#2

Hi there,

It's always a good idea to post what the task is asking for as well as it will allow people to help much more quickly.

To me it seems the issue you're facing is the fact you've included one too many curly braces (}):

var text = "Jason! Jason! Jason!"
var myName = "Jason"
var hits = []

for(var i = 0; i < text.length; i++) { //opens 1st for loop
    if(text[i] === "J")

        for(var j = i; j < (myName.length + i); j++) { //opens 2nd for loop
            hits.push(text[j]);
        } // closes second for loop
} // closes 1st for loop
} // not linked to anything?

If you get rid of the last curly brace the code will execute.

Hope that helps