5. Your second "for" loop


#1

I get a result of ...
['.',' ',undefined]
I've compared my code to some others that state theirs works. Other than the initial "string" and the name specifics, I can't see any thing.

var text = "I am named Mike. I have always been Mike and always will be Mike";
var myName = "Mike"
var hits = []
for (i = 0; i < text.length; i++){
if (text[i] === "M"){
for( j = i; j < (myName.length + i) ; j++); {
hits.push(text[j]);
}

}

}
console.log(hits);


#2

Don't forget to place your semicolons where they are needed.


#3

It's amazing that the semi colon behind my second "for" loop was killing the whole thing. Sometimes this can be extremely frustrating.


#4

most of the time a program doesn't work because of these small errors :smile: