Second for loop?


#1

Here is my code, I don't know what's wrong with it, please help.

/*jshint multistr:true */
var text = "Hey fellas, I name is chris and I am 23 years old.";
var myName = "Chris";
var hits = [];

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

if (text[i] === "C") {

    for (var j = i; j < (myName.length + i); j++) {

        hits.push(text.[j]);

        }

    }

}

#2

why do you have text.[j]? what is the . doing there? you want to access the letter in text at index j, which simply would be: text[j]

oh, and on line 1 where you declare the text variable, in the text variable chris should be spelled with uppercase first letter


#3

Oh great,

How can I make such an obtuse mistake?

Thanks a lot for your help though, the code works absolutely fine now.

Regards

Chris