Manipulate Arrays With Unshift II

In this lesson was it intentional that the instructions left out that you need to “myArray.unshift” and “myArray.shift” for the lesson to be completed?

The instructions read: Add ["Paul",35] to the beginning of the myArray variable using unshift() .

This is the answer “array” configuration that you should end up with: [ [ ‘Paul’, 35 ], [ ‘dog’, 3 ] ]

But this is the starting array: var myArray = [[“John”, 23], [“dog”, 3]];

But in order to get the answer sought you have to “.shift” first to remove the element at the front of the array, then use “.unshift” to add on the new element to the front of the array. I am asking about this for clarity on my part.

can you please provide the link to the challenge you are talking about?

the shift is already included in the starting code, you do not need to write it

2 Likes