When I create a new list item through the DOM and press the button again without refreshing the page, the old elements are not removed. Instead, the new ones are added on top. Any suggestions would be appreciated!
Here is the code snippet for reference:
data.cast.forEach((actors)=>{
const li = document.createElement('li');
li.innerHTML =
`<li>
${actors.actor}: ${ actors.character}
</li>`
cast.append(li)
})