3
How can I show the name, age and city at the same time on the screen and not just the name?
document.getElementById("demo").innerHTML = obj.name;
makes it show only the name inside that obj but I wanted to appear all the information about that obj.
// Storing data:
myObj = {name: "John", age: 31, city: "New York"};
myJSON = JSON.stringify(myObj);
localStorage.setItem("testJSON", myJSON);
// Retrieving data:
text = localStorage.getItem("testJSON");
obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name;
It worked! Thank you!
– David Mv
@Davidmv just be sure to mark this answer as correct, so people with the same problem can also be helped
– riki481