I have a problem with a section on the Codecademy JavaScript course. I read the instructions several times, and I even looked for other answers. I am stuck.
Here is my javascript
var text = "My name is Greyson because my parents named me Greyson.";
var myName = "Greyson";
var hits = [];
for (var i = 0; i < text.length; i++);
{
if(text[i] === "G")
{
for(var j = i; j < (myName.length + i); j++)
{
hits.push(text[j]);
}
}
}
When I click the submit button, it causes the following error:
" Oops, try again. It looks like your second 'for' loop is not pushing the value into the hits array. Make sure it works correctly and that the text myName appears somewhere in the text variable. "
I was looking for other people's answers to compare them, and it looks like mine is almost identical to some of the answers I received.
source
share