Don't get why it works


#1


so i passed the lesson, after much hardship, and i have realized it's probably because I don't get why it sees your name.


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++) {
			hits.push(text[j]);


it never says anything about searching the text, the closest it gets is to say stop when ii realy want to understand but i dont !(


#2

@star_wars_is_awesome,
Give us the FULL code you are using inclusive the text variable


#3

In truth, it does not "see" our name, and only matches the first letter. This is explained in the lesson text at some point.

The exercise builds an array of single letters. Once the first letter is found, the inner loop starting index is set to the current position, and that and the next myName.length -1 characters are pushed to the array.


#4

ok, then what tells it to find that part of the text


#5

In the outer loop, text[i] is the letter in the current index position, i. We can use this number as the starting index of the inner loop, where j = i to begin with.


#6

but what makes it scan, it just has beginning and end points and no more info, except how much to advance by


#7

it 'scans' one letter at a time (iteration).