Codington
0 of 8 problems solved • 0%

Exercise prompt

Remove with Pop

.pop() removes and returns the last array value.

Example

const sizes = ["S", "M", "L"]; const removed = sizes.pop(); console.log(removed); // outputs "L" console.log(sizes.length); // outputs 2

Predict the output

A packing list removes its final item. Predict both the removed item and the number left.

const items = ["book", "pen", "lamp"]; const removedItem = items.pop(); console.log("Removed:", removedItem); console.log("Remaining:", items.length);
What will this code print?