Command Palette

Search for a command to run...

Hectal
Phase 5: Arrays
JavaScript · Exercise 2 of 6 PreviousNext
Beginner

A shopping list with add and undo

Make the shopping list work. The list is stored in the items array.

Add puts the text from the box at the end of items (ignore empty or spaces-only text), clears the box, and redraws.

Remove last takes the last item off and redraws.

render() shows every item as an <li> in #list and the number of items in #count, like 2 items.

What Check tests

  1. Adding Milk then Eggs shows them in that order
  2. The count shows 2
  3. Empty or spaces-only text is not added
  4. The box is cleared after adding
  5. Remove last takes off the last item only

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.