how to save a variable in local storage javascript code example
Example 1: how to add variable to local storage in javascript
localStorage.setItem('key', 'value')
Example 2: javascript save data to local storage
// Store
localStorage.lastname = "Smith";
// Retrieve
document.getElementById("result").innerHTML = localStorage.lastname;
// Remove
localStorage.removeItem("lastname");