# Manipulate Arrays With pop()

## Problem Explanation

Get rid of the last element in the array. Then, assign that ridden element to `removedFromMyArray`.

## Hints

### Hint 1

Call `.pop()` on the array, and assign it to `removedFromMyArray`.

## Solutions

Solution 1 (Click to Show/Hide)
``````var removedFromMyArray = myArray.pop();

var arr = [1, 2, 3, 4, 5];
arr.pop(); // This got rid of 5
``````
1 Like

the instructions were
Use the .pop() function to remove the last item from myArray, assigning the â€śpopped offâ€ť value to removedFromMyArray.

my code was
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[1];
myArray.pop();

but it asks me to use pop() on myArrayâ€¦ anyhow the last element is already removed

2 Likes

This worked for me

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();

4 Likes