Doesnt just show my name, shows every letter with a captial A


I did add another way of displaying the name, but you can just ignore that.
My problem is that it shows every word that starts with a capital A instead of just my name, Alex.

/*jshint multistr:true */
var num = [];
var text = "code code code Alex code code Alex code code And code code Also code code Alex code";
var myName = "Alex";
var hits = [];

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


for(i = 0; i < num.length; i++) {


The exercise relies on the name being the only capitalized letter, but if you don't want this, you can also check the last letter (length -1 == "x"), just add another if statement inside the current if statement, or if you are familiar with the && use the and operator instead


Ah.. why couldnt i think of that ;-; haha thanks, thats a great idea! :slight_smile: