Currently I'm using this code to render my arrays as HTML:
// remove all the items
while (htmlElement.firstChild) {
htmlElement.removeChild(checkout.firstChild);
}
// re-add them + new ones
for(i of arr) {
let item = document.createElement("div")
htmlElement.append(item)
}
I run this function every time I make a change to my array. This isn't really efficient for larger arrays as I also delete/re-add all the items that weren't changed just to render a single change. Is there a more efficient and pretty solution?