How to make a timer in js

So I left my old projects and decided to make a website like trello.com it’s just a task list site and I wanted to make the task disappear after sometime but I don’t know how to create a time I tried to make astring nothing I tried everything I know help Here’s the js

//Don't care about the comment code
/*let todos = document.querySelector('ul')
let form = document.querySelector('form')
let idk = document.querySelector("[name='todo']")
let todo = []
*/
let timer = 80
/*function addtodos(todostext) {
  todo.push(todostext)
  const li = document.createElement('li')
  const button = document.createElement('button')
  li.innerHTML = todostext
  button.innerHTML = "done"
  todos.appendChild(li)
  li.appendChild(button)
}
form.onsubmit =(event) =>{
  event.preventDefault();
  addtodos(idk.value)
}*/
function minustimer() {
  --timer;
  
}

document.write(timer)

Answer

Inside an anonymous function of setInterval, you can remove the task item (instead of my console.log). The item will be removed after a specific amount of time given as a callback of setInterval. Basically, setInterval waits some time to execute a code block. More information in https://developer.mozilla.org/en-US/docs/Web/API/setInterval

function minustimer(){
    setInterval(()=>{
        console.log("Remove the item after 5000 milliseconds")
    },5000)
}

minustimer()