Can't see what i did wrong please help


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
            }//end of the loop2 execution
        }//end if execution
    } //end of the loop1 execution


instead of it being > shouldn't it be <


First problem is here, ,

where you type,

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


And instead of it being,

You should call hits.push with text[j]

So like,



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++) {

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


Thank you :grinning:`



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