Pushing Value to Arrays- code works but trying to understand


#1

On the arrays exercise I got my code to work but I want to really understand what is going on before I move on. Summarizing here, please feel free to correct me or add to it:
1. call a string that we are searching for a name in
2. define that name
3. define an array that we will send that data to
4. create a for loop that is a counter and runs up to the length of the name we are searching for
5. create a second loop, which is also a counter, that sends data to the array, and runs up to length of name
6. prints out a statement if we cant find the first variable of the name
7. Prints out each iteration of the name

I'm guessing this does not address if there are similar names?

Here is my code (lyrics courtesy of Big Black):
/*jshint multistr:true */

var text = "Hey little girl in US dress\
            Come and give daddy kiss\
            To Dead Billy US soldier in green\
            Little lady napalm butt\
            Come and give head to to\
            Dead Billy make you boom boom boom\
            Dead Billy";
var myName = "Billy";
var hits = [];
for (var i = 0; i < text.length; i ++){
    if (text[i] === myName[0]) {
        for (var j = i; j < (myName.length + i); j++){
        hits.push(text[j]);
        }
    }
}
if (hits.length === 0) {
    console.log("Your name wasn't found!");
    }
    else {
        console.log(hits);
    }

#2

Seems you understand it, you can always include console.log() to see what is happening.

Well, you could simple add a && operator to your if statement to also check the last letter