What's the problem?


#1

var text = "Text which contains Dani."
var myName = "Dani"
var hits = []
for (var i=0; i < text.length; i++){
if(text[i] === "D"){
for(var j = i; j <= i + myName.length; i++) {
hits.push[j]
}
}
}

It's not working. It looks like it crashes the browser, but I don't why would it be an infinite loop and what's the problem. Can someone help please?


#2

Here you accidentally incremented i instead of j. :slightly_smiling:


#3

Oh yes, thank you :smiley: