5/7 second for loop not pushing hits


#1

So this is my code:
var text = [" dklafjdf;jda Addison askldfjs\l;afkdjafkl Addison akjgdl;sgjdskl;gjaglkj\ Addison"] ;
var myName = "Addison";
var hits = [];
for (var i = 0; i < text.length; i++)
{
if (text[i] === "A")
{
for (var j = i; j < myName.length + i; j++)
{
hits.push(text[j]);
}
}
}
console.log(hits);

For some reason I keep getting the message that my text isn't being pushed into the hits array.


#2

@addisongatch

Get rid of the square brackets [] in var text. You also don't really need the "var" before "text".

It should look like this:

text = "dklafjdf;jda Addison askldfjs\l;afkdjafkl Addison akjgdl;sgjdskl;gjaglkj\ Addison";


#3

OMG Thanks u are really smart how come i havent known how to do that