Learn localStorage by Building a Todo App - Step 48

Tell us what’s happening:

Your code so far

const myTaskArr = [
  { task: "Walk the Dog", date: "22-04-2022" },
  { task: "Read some books", date: "02-11-2023" },
  { task: "Watch football", date: "10-08-2021" }
];

localStorage.setItem("key", "data", JSON.stringify(myTaskArr));
localStorage.setItem("key", "myTaskArr", JSON.stringify(myTaskArr));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 48

setItem takes two arguments, the key as a string and the data. When the challenge asks you to use data as the key it means localStorage.setItem("data", someData);

1 Like

localStorage.setItem(“myTaskArr”, JSON.stringify(myTaskArr));
localStorage.setItem(“data”, JSON.stringify(myTaskArr));

getting new error where Your localStorage.setItem() should have a key of myTaskArr .

You are not asked to use JSON.stringify remove that and only have one localStorage.setItem with the asked for string/data.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.