- Array to hold services requested
- Buttons to add service to array
- Place to display data from array - updated every time the array changes
- Once for same service
- Total costs stays updated
- Button to remove item from array
- Button to submit/send invoice
- Array methods - forEach(), find(), findIndex()
- Event Object
- Localstorage
services.forEach(service => {
const {id, name, price} = service
servicesBox.innerHTML +=
`
<button class="services-btn" id=${id}>${name}: $${price}</button>
`
const item = services.find(service => service.id === target.id)
const item = services.findIndex(service => service.id === target.id)
box.addEventListener("click", (e) => {
const target = e.target
if(target.tagName === "BUTTON") {
const item = servicesCart.find(service => service.id === target.id)
servicesCart.splice(item, 1)
renderService(servicesCart)
}
})
localStorage.setItem("services", JSON.stringify(servicesCart))
servicesCart = (JSON.parse(localStorage.getItem("services")))