xxxxxxxxxx
//You have to convert the data into string
let object = {
name: "cyber-ninja"
}
let convertToString = JSON.stringify(object);
//localStorage.setItem takes in two argument in string. The first is key and the second is its value
localStorage.setItem("name", convertToString);
//To extract information from the local storage follow the following steps
//localStorage.getItem only takes in one argument, that is key
let convertToObject = JSON.parse(localStorage.getItem("name"))//It converts the stored data back into object
xxxxxxxxxx
// object we want to save
var myObject = { name: "simon", surname: "goellner" };
// convert to json string
var myJSON = JSON.stringify( myObject );