Lighten the Load
Easy+20 XP
Mission Briefing
The cargo hold is overweight! To prevent the ship from sinking, you must jettison the last added container and retrieve its manifest.
The Concept: Array Mutators (Pop)
The .pop() method removes the last element from an array and returns that element back to you. Like push, it permanently alters the original array.
Example:
let list = [1, 2, 3]; let last = list.pop(); // last is 3, list is now [1, 2]
The Objective
Your function receives an array inventory.
- Remove the absolute last item from the array using the
.pop()method. - Return only the item that was removed, not the remaining array.
01EXAMPLE 1
Input
inventory = ["Key", "Lock"]Output
"Lock"Constraints
- Return the removed element, not the array.
FundamentalsArraysMethods
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
inventory["Gold","Silver"]
Expected Output
Silver
Click RUN to test your solution