let todoarray = JSON.parse(localStorage.getItem("todos")) || [] function additem() { let text = document.getElementById("todoitem").value; //ošetření jestli je text je prázdný if(text.trim()=="") {return;} todoarray.push(text); console.log(todoarray); savetodos(); renderlist(); document.getElementById("todoitem").value = ""; } function savetodos() { console.log(JSON.stringify(todoarray)) localStorage.setItem("todos",JSON.stringify(todoarray)) } function renderlist(){ document.getElementById("todoList").innerHTML= ""; todoarray.forEach(createList); } function createList(value,index){ i = index+1 document.getElementById("todoList") .innerHTML += '