What is wrong with my code?


When I try to run the code I think it just crashes my browser. Also, it is not the computers error because I have tried it on multiple devices. I have compared my code with others and i see no error. Please help me figure out what the error is. I have searched on a lot of other forum topics about it and i have so far found nothing.

var text = "Hello, my name is Christian.";
var myName = "Christian";
var hits = []
for (var i = 0; i < text.length; i++) {
   if (text[i] === "C") {
   for (var j = i; j < (myName.length + i); i++) {


If your function doesn't run to end then you have an infinite loop, ask yourself why it would stop and then check if it does that.


Oh man. Thank you lol i knew it had to have been an infinite loop but couldnt figure out what was wrong. i had "i++" when it should have been "j++" in case anyone was curious. but thank you again, you really helped me to just analyze it carefully.


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