Browser crashes after running code


#1



Your second "for" loop


None. Just page crash


Replace this line with your code. 
/*jshint multistr:true */

var text = "Chicken is only good if Conner cooks it right";

var myName = "Conner";

var hits = []

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


#2

Infinite loop, check your conditions
(the code runs in your browser, not on a server. the infinite loop will make your browser really busy and how your browser responds to that.. might depend on your browser and os, i guess, don't really know if there are any standards about that)


#3

for(var j = i; j < (myName.length + i); i++)

here it should be j++, not i++.

Your infinite loop occurs because you happen to have a "C" at i-index position 1.

So the line here, whether written correctly or not, loops eternally due to the middle condition:

for(var j = i; j < (myName.length + i); j++)

it means:

for (var 1 = 1; 1 < (6 + 1); j++)

If j = i which is 1, j will forever be less than myName.length + 1.