Your Second "For" Loop - stuck in an infinite loop


#1


I cant run the code because its in an infinite loop byt i do not know how to fix the infinite loop. any solutions?

/*jshint multistr:true */

var text = "Hello, My Name Is Jake. / Nice To Meet You.";
var myName = "Jake";
var hits = [];

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


Replace this line with your code.


#2

Hi Jake,

I'm also working on this activity. Why did you write (var j = i; j < i+myName.length; i++) { ?

Shouldn't it be the following:
for (var j = i; j < i+myName.length; j++) {


#3

Ohhhhhhhhhhh, Thanks. I Was Confused There. Thanks for pointing that ouy


#4

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