Your second "for" loop


I'm joining the club for this one. I'm not sure what I've done wrong. Any help would be appreciated.

I'm getting the "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." error.


/*jshint multistr:true */

var text = ("This is Aaron a long string of text so Aaron the program can look for my Aaron name in it.");

var myName = ("Aaron");

var hits = [];

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


for ( var i = 0; i < text.length; i++); // remove ;


( var j = i; j < (i + myName.length); j++); //same here


Thanks. That did it.


Got mistake: SyntaxError: Unexpected token )

I don't understand what it means

Help please!

/*jshint multistr:true */

var text = "Hey, how are you \
doing? My name is Emily.";
var myName = "Emily";
var hits = [];

for (var i=0; i < text.length; i++){
if (text[i]==='E') {
for (var j=i; j<(i+myName.length), j++){


Try refreshing the browser.


Why does "i + myName.length" have to be in parenthesis?

Can anyone explain?


it depends on's not compulsory :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.