Free Code Camp: Manipulate Arrays With push/pop/shift/unshift
Manipulate Arrays With push
Instructions:
- Push ["dog", 3] onto the end of the myArray variable
- myArray should now equal [["John", 23], ["cat", 2], ["dog", 3]]
Manipulate Arrays With pop Instructions:
- Use the .pop() function to remove the last item from myArray
- assigning the "popped off" value to removedFromMyArray
- myArray should only contain [["John", 23]]
- Use pop() on myArray
- removedFromMyArray should only contain ["cat", 2]
Manipulate Arrays With shift
Instructions:
- Use the .shift() function to remove the first item from myArray
- assigning the "shifted off" value to removedFromMyArray
- myArray should now equal [["dog", 3]]
- removedFromMyArray should contain ["John", 23]
Manipulate Arrays With unshift
Instructions
- Add ["Paul",35] to the beginning of the myArray variable using unshift()
- myArray should now have [["Paul", 35], ["dog", 3]].