Add and Remove Phone Numbers
Write the code, see it run, pass the checks.
The problem
- medium
- Code
A contact form starts with one text input labelled "Phone 1". An "Add phone" button adds another field below the others, labelled "Phone 2", then "Phone 3"; three is the most, so Add phone is disabled at three. Each field has its own remove button named "Remove phone 1", "Remove phone 2" and so on (an aria-label is fine). Removing a field keeps what was typed in the others and renumbers the labels, so removing Phone 1 makes the old Phone 2 the new Phone 1. The last field left can't be removed: its remove button is disabled or not shown.
Your code must pass
- Add phone adds a numbered field
- Add phone is disabled at three fields
- Removing a field keeps what was typed in the others
- The last field can't be removed