I completed the syntax, but i dont get what the hits[ ] variable actually did


/*jshint multistr:true */
var text= "Hey hows your day going so far chris?";
var myName="chris";
var hits=[];

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




My code DOES works I just want a better understanding of the hits [ ] array. Thank you.

Replace this line with your code.


Also, I have added and if statement to the end of my syntax....

console.log("Your name wasn't found!");
After I hit save and submit the console does log my name but it also logs a long list of 'undefined' strings...did this happen to everyone or is it just me? please give me some feedback. Thank you as always!


for(x=i; x hits.push(text[x]);

make sure there is no [i] on the second for loop.
The hits[] form what I understood is just declaring a empty array that you will be adding values into which you did using the ,push method.

hope this helps.


for(x=i; x hits.push(text[x]);