5 your second "for" loop


#1

var text = "Robert loves beer. Everyone that\
Robert went the beer was sure to go. This made\
Robert happy!";

var myName = "Robert";

var hits = [];

for (var i = 0; i < text.length; i++){
}

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

https://www.codecademy.com/en/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661#

I am getting a parser error and I cannot figure this out.


#2

if( text[i] === "R") {
for (var j = i; j < (i + myName.length); j++){
hits.push( text[j] );
}  // closing for-loop
} //closing if
} // what is this for?

read comment


#3

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