Unexpected Token }


#1


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


My code pops up with the error SyntaxError: Unexpected token }


var text= "I love corgi's my name is Tayler. But I love Corigs more then Phillip does Tayler";
var myName="Tayler";
var hits=[];
/*jshint multistr:true */

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


#2

your code should look like

for(var i=0; i<=text.length; i++){ //opening bracket for for-loop
  if(text[0]==="T"){            //opening bracket for if
    for(var j=i; j<i+myName.length; j++){ // opening bracket for for-loop
     hits.push(text[j])
} //closing bracket for second for-loop
} //closing bracket for if
} //closing bracket for first for-loop

read my comment


#3

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