Javascript » Data » Remove items from an Array
👉 User Story:
As a user
Given an Array that renders into an HTML list
When I click on a particular item
That item should be removed from the array
The architecture of the "render" function from the previous step should change into something like this:
- clear existing DOM items
- for each item in the array
- create the new item
- associate the event to handle the delete
- add the item to the list
You can try things out directly on this pen:
https://codepen.io/marcopeg/pen/ExxROxe
✅ Proposed Solution:
Don't run this unless you gave a very good effort to solve it yourself!
An alternative solution:
And another: