2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Manipulate Arrays With pop()
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Manipulate Arrays With pop()
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
2018-10-12 15:37:13 -04:00
|
|
|
## Problem Explanation
|
|
|
|
|
|
|
|
Get rid of the last element in the array. Then, assign that ridden element to `removedFromMyArray`.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
|
|
|
|
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
Call `.pop()` on the array, and assign it to `removedFromMyArray`.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
```javascript
|
|
|
|
var removedFromMyArray = myArray.pop();
|
|
|
|
|
|
|
|
var arr = [1, 2, 3, 4, 5];
|
|
|
|
arr.pop(); // This got rid of 5
|
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
</details>
|