title: Undo Functionlity on Badminton Scoreboard
body: <p>I have this code: 
  <a href="https://codepen.io/Jigz1986/pen/GLWppM" rel="nofollow noreferrer">https://codepen.io/Jigz1986/pen/GLWppM</a> which is a simple badminton score-keeper. The serve logic is an important thing here. </p>
  
  <p>I have somehow created a logic to make changes on FrontEnd depending on the score.  I am not able to crack how to bring the undo functionality here.</p>
  
  <pre><code>
      else if (target.id==='undo2' &amp;&amp; t2 &gt; 0){        reverse ();     document.getElementById("pt1").innerHTML = t2-1;    }
  
      else if (target.id==='undo1' &amp;&amp; t1 == 0){alert("Can't Undo!")   }   
  
      else if (target.id==='undo2' &amp;&amp; t2 == 0){alert("Can't Undo!")   } 
  </code></pre>
  
  <p>There are ways like immutable.js etc, which are way lengthier than expected.</p>
  
  <p>Can anyone help me with JS so that upon clicking undo button (n number of times and not going below 0) all the previous state will be shown?</p>
  
  <p>If required, we can use undo only once, then after it will be disabled. But it will be enabled only after '+1' is pressed. This may be done because we want to save just the last set of changes, instead of keeping track of all the historical changes we can limit this to just the last change.</p>
  
  <p>Do Note: changing background colour is an important thing.</p>