Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
Delete all completed items from list and update local storage

I am working on a to-do list project. I want to delete all those items at once which have lines through them by clicking the "clear all completed" button. when I check the box two things happen. First a class by name of "clicked" is added, which does text-decoration: line through. Secondly, It changes the completed boolean from false to true in local storage. you can check the picture below. I am trying to use the filter method, but, I am unsuccessful. Could anyone please help me, how to delete those items at once, along with removing them from local storage too, which have lines through them.

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I would save Completed as a boolean value instead of a string, but with your data as it currently stands, here's one way of doing it:

Example

const allTasks = localStorage.getItem('todo-list')
const incompleteTasks = allTasks.filter(task => task.Completed === "false")
localStorage.setItem('todo-list', activeTasks)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda