Site crashes, but I don't think I made an infinite loop


#1

So I'm on the third exercise of the for loop lesson, and I go to save and submit, but the sit crashes!
Here's the code:
var text = "Michael bleh bleh Michael"
var myName = "Michael"
var hits = []
for (var i = 0; i = text.length; i++) {
}
Please let me know what I did wrong or if it's the site! Thanks!
P.S. This is my first post and I am also a beginner to programming. Wish me luck!


#2

The problem is that you did create an infinite loop. You assigned i to text.length. You should change the loop syntax to:

for (var i = 0; i <= text.length; i++) {

#3

Oooooooh thats what I did! Thanks!


#4

You're welcome! :slightly_smiling: