title: How to store countdown in local storage
body: <pre><code>function counter1() {
  
      var counter = 5;
  
      setInterval(function() {
  
          counter--;
  
          if (counter &gt;= 0) {
  
              var id = document.getElementById(&quot;res&quot;);
  
              var bet = document.getElementById(&quot;pts&quot;);
  
              var on = document.getElementById(&quot;bet&quot;);
  
              var beth = document.getElementById(&quot;beth&quot;);
  
              var betv = document.getElementById(&quot;betv&quot;);
  
              id.innerHTML = &quot;Results after&amp;nbsp;&quot; + counter + &quot;&amp;nbsp;seconds&quot;;
  
              beth.disabled = true;
  
              beth.style.backgroundColor = &quot;rgb(229, 229, 229)&quot;;
  
              betv.disabled = true;
  
              betv.style.backgroundColor = &quot;rgb(229, 229, 229)&quot;;
  
              beth.style.cursor = 'none';
  
              betv.style.cursor = 'none';
  
          }
  
          if (counter == 0) {
  
              counter2();
  
              var beth = document.getElementById(&quot;beth&quot;);
  
              var betv = document.getElementById(&quot;betv&quot;);
  
              beth.disabled = false;
  
              beth.style.backgroundColor = &quot;#4CAF50&quot;;
  
              betv.disabled = false;
  
              betv.style.backgroundColor = &quot;#008CBA&quot;;
  
              beth.style.cursor = 'pointer';
  
              betv.style.cursor = 'pointer';
  
              var random = Math.floor((Math.random() * 100) + 1);
  
              var id1 = document.getElementById(&quot;res1&quot;);
  
              if (random &lt; 50) {
  
                  id1.innerHTML = &quot;Heroes have won&quot; + random;
  
              } else {
  
                  id1.innerHTML = &quot;Villains have won&quot; + random;
  
              }
  
          }
  
      }, 1000);
  
  }
  
  function counter2() {
  
      var counter = 5;
  
      var on = document.getElementById(&quot;bet&quot;);
  
      setInterval(function() {
  
          counter--;
  
          if (counter == 9) {
  
              on.innerHTML = &quot;&quot;;
  
          }
  
          if (counter &gt;= 0) {
  
              id = document.getElementById(&quot;res&quot;);
  
              var bet = document.getElementById(&quot;pts&quot;);
  
              id.innerHTML = &quot;Bet within&amp;nbsp;&quot; + counter + &quot;&amp;nbsp;seconds&quot;;
  
          }
  
          if (counter == 0) {
  
              counter1();
  
          }
  
      }, 1000);
  
  }
  </code></pre>
  <p>I want this code to be stored in local storage ( countdown) ,,I want those countdown to be retrieved on page load, would appreciate if I could get some suggestions or if anyone could modify the code. is it possible to modify it from here to store countdown in local storage or should I recode from the beginning would appreciate on suggestions and ideas. Thank you!</p>