What is "hits.push(text[y]); " functions


#1

im at my wits end trying to find the definition of the "hits.push(text[y]);" part of the coding. Google, the glossary, the explanation.... i probably just need human help.

my code works, i just need a clarification on what that part of the code does in slow terms.


#2

.push() is a method applied to an array which adds a new element to its end.

hits.push(text[y]);
// hits is the array
// push is telling computer that it must add the element to the end of the array
// text[y] is that element which computer will add to the array
// text[y] returns the yth letter of the string which the "text" variable contains
// remember that computer starts counting from 0, so, for instance, the 3rd letter is the 2nd for computer

#3

thank you! this really helped!