Infinite Loop on second "for" loop?


I've been playing with this coding, reading the forum and watching tutorials for hours now and I can't understand why my code isn't working. Whenever I go to input it, the page crashes. Q&A says this is because it's an infinite loop. Can anyone tell me what I'm doing wrong?

var text= "Blah blah blah blah blah Sophie blah blah blah Sophie blah blah blah Sophie.";
var myName = "Sophie";
var hits = [];

for(var a = 0; a < text.length; a++){
for(var b = a; b < (myName.length + b); b++){

Thank you in advance!


Hey kolans,

in your second for statement, the second part of it should be using the a variable instead of using b. The use of your b variable is whats causing the infinite loop. Since b is comparing to something, it needs an outside, defined variable to compare itself to, like a.

Hope this helps!