5. Your second "for" loop help



In this lesson, everything seems to be going well except I ran into a problem at the second for loop. This may sound stupid, but I'm sure how to stop my loop 'When it hits the value of the first iterator (say, i) plus the length of your myName variable.' if somebody could break it down so it's much easier to understand it'd be very appreciated. Thanks in advance!

var text = "Ibra Ibra Ibra";
var myName = "Ibra";
var hits = [];

for(var i = 0; i > text.length; i++) {
    if (text[i] === myName[0]) {
        for(var j = i; j > /*area where I don't know what to do */; j++) {


Alright, I fixed the problem. Turns out I actually had the wrong operator for the second area of the for loop, which was why I was confused. When I flipped the > with < I got it correct.

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


Nicely solved, i wrote a rather extensive answer yesterday on this question, you can find it here, maybe worth the read


I probably should've looked there first!


You can also search the forums for more reply's, there are many good answer which explain the second for loop, to improve your understanding


Will do! What a great way to improve