How do I use pop() for multi-dimensional arrays?

How do I use pop() for multi-dimensional arrays?
0

#1

Tell us what’s happening:
How do I pop() from multi-dimensional array. For eg if I want to pop() “cat” from myArray.

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 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0.

Link to the challenge:


#2

You would need to pop from the sub-array
var removedFromMyArray = myArray[1].pop(); // “cat”


#3

That is exactly what I tried doing but fcc showed me some error message


#4

Actually, that would only remove the 2 from the second array.


#5

Oh ok sorry. So sorry for bothering you guys.The error was just relating to the lesson at hand.

edit: When I looked at the console it gave me the answer I was hoping for.


#6

:octopus: Oops.
Way not to pay attention, Ariel. :stuck_out_tongue: