5. Your second for loop. Help!


#1



/*jshint multistr:true */
var text = "Bruce Lee Bruce Lee Bruce Lee Bruce Lee Bruce Lee \ Bruce Lee";
var myName = "Bruce Lee";
var hits = [];
for(var text = 0; text < myName.length; text++) {

}
if(text[text] === "B") {

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

5. Your second for loop


Oops, try again. There was a problem with your syntax.


Replace this line with your code.


#2

Hey @bitslayer20589

The problem is the variable you are using to iterate over text variable. Like in this part you declare your first text variable

But then if you look in your for loop

You reuse text variable as counter when it is already defined as a string in your code. I suggest you renaming the text counter as i variable like iteration.

Hope you're having a great day!


#3

/*jshint multistr:true */
var text = "Bruce Lee Bruce Lee Bruce Lee Bruce Lee Bruce Lee \ Bruce Lee";
var myName = "Bruce Lee";
var hits = [];
for(var text = 0; i < myName.length; text++) {

}
if(text[text] === "B") {

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


#4

/*jshint multistr:true */
var text = "Bruce Lee Bruce Lee Bruce Lee Bruce Lee Bruce Lee \ Bruce Lee";
var myName = "Bruce Lee";
var hits = [];
for(var text = 0; i < myName.length; text++) {

}
if(text[text] === "B") {

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

still can't...


#5

You're reusing the text variable as a loop counter.


#6

and your first 2 for loops immediately end themselves and the last 2 semicolons should give you a syntax error.


#7

You should not be using the same variable "text" again in the loop. Define a new variable. Say I for eg.