Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
Cuando ingreso el elemento, el elemento anterior no desapareció en la matriz

https://youtu.be/bTx08ox0zA8

En el video, ingrese el elemento "to Do" nuevamente a las 3:54, el antiguo "to Do" desaparece. Pero no desapareció en mi proyecto.

así que miré cuidadosamente mi código…

 const toDoForm = document.querySelector("#todo-form"); const toDoInput = document.querySelector("#todo-form input"); const toDoList = document.querySelector("#todo-list"); const TODOS_KEY = "todos"; const toDos = []; function saveToDos(){ localStorage.setItem(TODOS_KEY, JSON.stringify(toDos)); } function deleteToDo(event){ const li = event.target.parentElement; li.remove(); } function paintToDo(newToDo){ const li = document.createElement("li"); const button = document.createElement("button"); const span = document.createElement("span"); span.innerText = newToDo; button.innerText = "✔"; button.addEventListener("click", deleteToDo); li.appendChild(span); li.appendChild(button); toDoList.appendChild(li); toDos.push(newToDo); saveToDos(); } function handleToDoSubmit(event){ event.preventDefault(); const newToDo = toDoInput.value; toDoInput.value=""; paintToDo(newToDo); } toDoForm.addEventListener("submit", handleToDoSubmit); const saveToDo = localStorage.getItem(TODOS_KEY); if (saveToDo !== null){ const parsedToDos = JSON.parse(saveToDo); parsedToDos.forEach(paintToDo); }

entonces descubrí que

 toDos.push(newToDo); saveToDos();

deberían existir en function paintToDo no en una function handleToDoSubmit

En el video, ingrese un elemento nuevo en la matriz en la web => elemento antiguo desaparecido en la matriz. Cuando lo hice con mi código, el elemento antiguo aún existe en la matriz con el elemento nuevo

Quiero entender por qué no ocurre el error y cómo el resultado es diferente entre el video y mi código.

¿Alguien puede ayudar con esto?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!