What am I doing wrong here? Step 6


It gives me an error saying that the second for loop isn't pushing values to the hits array.

/*jshint multistr:true */
var text = "bbbbbbbbabbbbbbbbbbAndrewbbbbbbbbbbbbbAndrewbbabbbbbbb";
var myName = "Andrew";
var hits = [];

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



if(text[i] === "A").


Hi @dennisaj5

You can replace it : myName.charAt(0) because you want to find "A" (index 0 of your string variable "myName")
Next, if you want push your name in "hits", you must change text[i] to text[j] in line 8

Hold on :wink:


Believe it or not if you do the following the code will work:

if (text[i] === myName[0]) {

What you're telling the code is that it wants to take the first value it has in myName, which would be "Andrew" What I am not sure of however, is if it just lists the first character or the whole name. All I know is that when I did this lesson that's how I completed it.