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.

  1. Remove the absolute last item from the array using the .pop() method.
  2. Return only the item that was removed, not the remaining array.

01EXAMPLE 1

Inputinventory = ["Key", "Lock"]
Output"Lock"

Constraints

  • Return the removed element, not the array.
FundamentalsArraysMethods
JavaScript
Loading...
3 Hidden

Input Arguments

inventory["Gold","Silver"]

Expected Output

Silver

Click RUN to test your solution