Your second "for" loop


I don't know whats wrong with this code can someone help me, please.

Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token

var text = "Aaron likes pi. Aaron also like cake. Aaron likes food in general.";
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++) {


It would seem that all your } are unnecessary alteast according to my work on this lesson. Also a ; is needed after [] Other than that your answer is the same as mine with a different name


for (var j = i; j < (i + myName.length; j++) // missed a ) after myName.length


 hits.push((text[j]);  //here remove a ( you added a extra


wow that worked thank you


Thank you for the help as well I would have never noticed that


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