6/7 It works! I just don't know how


#1

Hi,
This is my first topic, hope I formatted it correctly..

It all works as it should, I just need to understand this part : j < (myName.length + i)
Can someone please tell me what happens after this:

if (text.substring(i,i+myName.length)===myName) {

Here's the code

/*jshint multistr:true */

var text="blkjgijkhlabelgljhbnknlkmnl'mn'nkm/l,:"
var myName="abdel"
var hits=[]

for (var i=0; i < text.length; i += 1) {
if (myName[0] === text[i] ) {
    if (text.substring(i,i+myName.length)===myName) {
        for (var j = i; j < (myName.length + i); j += myName.length) {
        hits.push(text.substring(i, j+myName.length));
    }
    }
    }
}
    if (hits.length === 0){
        console.log("Your name wasn't found")
        }
        else
        {
            console.log(hits);
        }

#2
var text="blkjgijkhlabelgljhbnknlkmnl'mn'nkm/l,:"
                    |   ^
                    i   |
                    j----