Dont understand what is this push method?


#1

var text = "hatim hatim hatim";
var myName = "hatim";
var hits = [] ;
for(var i = 0; i < text.length; i++);{
if(text[i] === "h"); {
for(var j = i; j<myName.length + i; j++); {
hits.push(
}
}}

please assist how does the hits.push work? thank you


#2

The push() method adds new items to the end of an array, and returns the new length.
So, you're adding the returned names to the array "hits."

Hope I helped, wish I could explain better. :slight_smile:


#3

HI, alright, but how do i code it then?


#4

What do you mean with "how do I code then" ?


#5

This topic was automatically closed after 7 days. New replies are no longer allowed.