# 7/7: what is the +i for in the (myName.length + i)

#1

text = "Blah blah blah blah blah blah Eric \
blah blah blah Eric blah blah Eric blah blah \
blah blah blah blah blah Eric";

var myName = "Eric";
var hits = [];

// Look for "E" in the text
for(var i = 0; i < text.length; i++) {
if (text[i] === "E") {
// If we find it, add characters up to
// the length of my name to the array
for(var j = i; j < (myName.length + i); j++) { /---what is that i doing exactly? shouldn't myName.length be enough for the code to run?---/
hits.push(text[j]);
}
}
}

if (hits.length === 0) {
It is necessary to offset the ending position to match the start. If `j` begins at `i`, then it must end some myName.length positions further to the right. If we don't add `i`, we will not have the correct ending index.