title: How to use localStorage in HTML
body: <p>Sorry, I'm new to HTML and after hours I could make my function. But every time I refresh the page, the number is going back to 0. Can anyone add localStorage to my function below (Sorry if I said something that doesn't make sense, I'm new)</p>
  
  <pre><code>function answer() {
      document.getElementById("answer").innerHTML = "&lt;xmp&gt;&lt;/h4&gt;&lt;/xmp&gt;";
      }
  function add() {
      var num = document.getElementById("result").innerHTML;
      if(num == '') num = 0;
      document.getElementById("result").innerHTML = parseInt(num ,10) + 500;
      }
  
  function sub() {
      var num = document.getElementById("result").innerHTML;
      if(num == '') num = 0;
      document.getElementById("result").innerHTML = parseInt(num ,10) - 500;
      }
  </code></pre>