6. Log it! Code passes but my name isn't printing


#1

/*jshint multistr:true */
var text = "Dkfsdfj fkdjfsdff, fdslfjkg Alex. SDKfjg skdlf fkdfj adskfj, fsdkjfl dkfjgkj fdfkj Alex.";
var myName ="Alex";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === "A") {
for (var j = i; j === (i + myName.length); j++) {
hits.push(text[j]);
};
};
}
if (hits.length === 0) {
console.log("Your name wasn't found!");
}
else {
console.log(hits);
}

I finally got this code to pass by fixing a couple of syntax errors, but console.log prints "Your name wasn't found!" and I have no idea why. If I did everything correctly shouldn't it have found my name? Please help.


#2

@mthfrnd,

Have a close look at the condition of your 2nd FOR-loop

j === (i + myName.length);