Need help


#1


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


Oops, try again. There was a problem with your syntax. and SyntaxError: Unexpected token , and Expected ')' to match with '(' from line 7 and instead saw ';'.
Expected an identifier and instead saw ')'.


/*jshint multistr:true */
var text = "hello there Gary, My name is Gary. What is your nameGary?Is it Gary, or Gary?I like the name Gary.Blah blah Gary, Gary, Gary.I like chicken Gary.Do you like it too Gary?";
var myName = "Gary";
var hits = [];
for(var i =0;i < text.length;i+=1){
    if(text[i] ==='G'){
        for(var j = i;j < myName.length + i;j++;);{
            hits.push(text[j]);
        }
        
        }
}


#2

Your second for is slightly wrong. You need to add set of parenthesis to the myName.length + i. Your finished if should look like this.

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

If that was solved your code please mark my reply as the solution. :slight_smile:


#3

its good now.thanks for helping!


#4

Your most certainlyy welcome. Can you please mark my reply as the solution?


#5

how do you mark your reply as the solution?:confused:


#6

Under my first response to the left of the reply button there are 3 dots, click that then click the mark as solution button.


#7

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