Page gets stuck at exercise 5, could not submit code


Hi, can someone help me with this? What's wrong with my code?

var text="Ruth is currently looking for a new job. Ruth has been asking her friends for some suggestions"
var myName="Ruth"
var hits=[ ];
for (var i=0; i<text.length; i++)
{if (text[i]==="R")
{for (var j=0 ; j<i+myName.length; i++)



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

You should be incrementing j now, not I. I++ will keep incrementing i.


beside the fact that you should increase j (thanks to @hauboldj) in your second for loop, j should also be set to i, since you want to find all instances of your name.

i will hold the index of the first letter of your name thanks to the if statement


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