Undo and Redo
Write the code, see it run, pass the checks.
The problem
- hard
- Code
- Pro
A shopping list has a text input labelled "Item" and an "Add" button; adding clears the input, and blank items aren't added. Each item has a button labelled "Remove" and its name, e.g. "Remove Milk". Add "Undo" and "Redo" buttons: Undo reverts the last add or remove, Redo puts it back, and any new change after an undo clears what could be redone. Each is disabled when there's nothing to undo or redo.
Your code must pass
- Undo and Redo start disabled
- Undo reverts an add, Redo puts it back
- Undo reverts a remove
- A new change clears Redo