Lo que quiero hacer es que cuando haga clic en el botón Sí, se eliminen todos los elementos, y cuando haga clic en el botón de reinicio, todo vuelva, y tantas veces. Lo que obtengo: Presiono el botón "sí", todo se elimina, luego el botón "reiniciar", todo vuelve, quiero presionar el botón "sí" nuevamente, pero nada más funciona
const body = document.querySelector('.body'); const message = document.querySelector('.message'); const reset = document.querySelector('.panel__close') const bodyMessage = document.querySelector('.body__message') function removeChilds(childs) { for(const child of childs){ child.parentNode.removeChild(child); } } let childs = []; function create() { // here created elements for programm... childs.push(bodyError, bodyErrorImage, bodyText, bodyButtons, bodyButton1, bodyButton); // the created elements are pushing into the array } create(); yes.addEventListener('click', () => { // here deleting all elements and creating congratulation removeElements(childs); childs = []; // created congratulation const paraLox = document.createElement('p'); paraLox.textContent = 'Congratulation, Jaba is work!'; paraLox.style.fontSize = '3rem'; paraLox.style.textAlign = 'center'; paraLox.style.fontWeight = '1000'; paraLox.style.color = 'red'; body.appendChild(paraLox); // reset.addEventListener('click', () => { // reset button paraLox.parentNode.removeChild(paraLox); create(); }); });