Determining which value to be popped off

Tell us what’s happening:

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 removedFromMyArray = myArray.pop();


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; CrOS x86_64 9901.77.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.97 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/manipulate-arrays-with-pop

How do I know which one it is to be popped off?

.pop() always removes the last element of the array, .shift() always removes the first.

1 Like

Thanks. It was really helpful.