6/7 Getting too many results


Hi guys
My code is running correctly. But i'm getting way more results than are in my text. also other words starting with I, which are supposed to be pushed through as well aren't shown, did I do something different?

this is my code:
var text = "Hello everyone, my name is Issa. What's up? \
blah blah Issa blah blah Issa. \
I'm 17 years old. Issa. Isa. Isssa";
var myName = "Issa";
var hits = [];

for (var i = 0; i <= text.length; i++) {
if (text[i] === "I") {
for (var j = i; j < (i + myName.length); j++) {

if (hits.length === 0 ) {
console.log("Your name wasn't found!");
} else {


In you second loop you should push only text[j] in hits.
Now you are pushing you name 4 times (the count of letters in myName) for every time you found your name in "text".


Thank you very much!