FateAssassinF
Reactiflux2y ago
14 replies
FateAssassin

✅ – fateassassin – 18-10 Jun 5

    var todoItems = JSON.parse(localStorage.getItem("todos"));
    var id = null;
    try{id = todoItems[todoItems.length - 1].id + 1;}
    catch{id = 1;}

    todoItems.push({
        "id": id,
        "todo": todo
      }
    );
    alert(JSON.stringify(todoItems));

I've got a question, why does the dict i try to push only contain the ID? It just doesnt contain the todo
Was this page helpful?