Javascript: Array manipulation using push() Part1

Arrays are an important part of javascript. There are situation where you may want to add more items to an array at run time. In order to add a new item to the end of an Array, we use the push() function.
.push() takes one or more parameters and pushes them to the end of the array
var arr = [1, 2, "three", 4, "hello"];
The resulting arr will now contain: 
 [1, 2, "three", 4, "hello", "good"]
 You can also pass multiple item to .push(), e.g:
arr.push("best", 4, "amazing");
I hope you now are now familiar with .push() function. In the next blog post, I will explain the pop() function.
Task: Consider the following array
var fruits = ["apple", "banana", "orange"];
Add two more fruits to the fruits array using .push() function.
Please post your answer in the comments.


Mohammad A.

Professional Software Developer with 12+ years of Experience

if (isMyPost) { }