title: How to store previous result into a var
body: <p>Pretty new to Javascript..</p>
  
  <p>I have managed to script this simple code here:</p>
  
  <pre><code>var currentstock = 50;
  
  function stockminus(x){
      newcurrent = currentstock - x;
      return newcurrent;
  };
  console.log(stockminus(10));
  </code></pre>
  
  <p>the output of this must be : <code>40</code></p>
  
  <p>How can I store that new output into <code>currentstock</code> as the new value or in other words overwrite that var?</p>
  
  <p>so next time I call that function again, output should be : <code>30</code>
  Becasue the new currentstock is <code>40</code> from the previous call</p>