Bug on 5.Your second "for" loop


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661

There is a bug when i click on Save & Submit code, the site crash and i can't go to the next lesson.

Replace this line with your code. 

/*jshint multistr:true */
var text = "Hi Francesco how are you?";
var myName = "Francesco";
var hits = [];
for (var i = 0; i < text.length; i ++){
    if (text[i] === 'H'){
        for (var j = i; myName.length; j ++){
            hits[j];
            };
        }
    };


#2

sounds like a bug in your code (to be precise, a infinity loop)

Please copy paste your code to the forum so we can check it


#3

usually in that case a red popup appears


#4

look at the condition of your second for loop:

myName.length

this will never evaluate to false, so you have an infinity loop

What does the condition needs to be?


#5

Solved! Thank you :relaxed:


#6