Can't see what i did wrong please help


#1


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

Says I have an unexpected token

/*jshint multistr:true */

var text="hey,how are you \
doing? My name is Bill.";
var myName="Bill"
var hits=[]
for(i=0;i>=text.length;i++){//start of the loop1 execution
    if(text[i]==='B'){//start if execution
    for(var j=i;j=0;j>=3;j++){//start of loop2 execution
    hits.push(myName.length);
            }//end of the loop2 execution
        }//end if execution
    } //end of the loop1 execution


#2

instead of it being > shouldn't it be <


#3

First problem is here, ,

where you type,

Instead it should be
j < i + myName.length;


#4

And instead of it being,

You should call hits.push with text[j]

So like,

hits.push(text[j]);

#5

When declaring a variable, you should put a semicolon at the end of the line
ex: var myName = "Bill";
In your 1st "for" loop, you want i to be less than text.length ( i < text.length;)
In your 2nd "for" loop, you don't need j = 0 or j >= 3. Should read:
for (var j = i; j < (myName.length + i); j++) {
hits.push(text[j]);
}

Hope this helps. Let me know if I can explain it any better!


#6

Thank you :grinning:`

`


#7

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