Second for loop is killing me


#1


var text = "Kathy case manager Mastic Beach street bus";
var myName = "Kathy";
var hits = [];
for (var i=== 0; i < text.length; i++)
{
if (text[i]=== "K") {
for (var j=== i; j < (i + myName.length); j++)
{
hits.push(text[j]);
}
}
}
console.log(hits);


SyntaxError: Expected ';'


Replace this line with your code.


#2

First problem,

in the begin you are just setting i = to 0 but instead you used the assignment operator ===, should be,

for (var i=0; i &lt; text.length; i++)

Same problem here,

for (var i = 0; i < text.length; i++)

not,

Lastly,

You need to close your last bracket with a semi colon, ;


#3

You are wonderful. I will definitely pay closer attention. Thank you!!!


#4

You're welcome :slight_smile:


#5

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