let todoarray = JSON.parse(localStorage.getItem("todos")) || []; function additem() { let text = document.getElementById("todoitem").value; // jestli text je prázdný tak ukončí celou funkci if (text.trim() == "" ) {return;} todoarray.push(text); console.log(todoarray); savetodos(); renderlist(); document.getElementById("todoitem").value = ""; } function createlist(value, index){ i = index+1 document.getElementById("todolist") .innerHTML += '
  • '+i+". "+value +'
  • '; } function removeitem(index) { todoarray.splice(index,1); savetodos(); renderlist(); } function renderlist(){ document.getElementById("todolist").innerHTML = ""; todoarray.forEach(createlist); } function savetodos(){ console.log(JSON.stringify(todoarray)); localStorage.setItem("todos",JSON.stringify(todoarray)); } renderlist();