Manipulate Arrays With pop()!

Manipulate Arrays With pop()!


Tell us what’s happening:
can you please explain to me how to remove and add pop?

Your code so far

// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var myArray = [["John", 23]]
var removedFromMyArray = myArray.pop ["cat" , 2]

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15.

Link to the challenge:


pop() removes the last element of the array and returns it. Look at the example code
var ourArray = [1,2,3];
This means ourArray has three elements 1,2 and 3.
When you apply pop() function to ourArray, it removes the last element(which is 3) and returns it and that is stored in the variable removedFromOurArray as shown in this line.
var removedFromOurArray = ourArray.pop();

Similarly to complete this challenge, you have to use pop() function to remove the last element([“cat”,2]) of the myArray and store it in the variable removedFromMyArray.