title: JavaScript global add function
body: <pre><code>var num;
  
  function newNum(num) {
      num += 1;
      return num;
  }
  </code></pre>
  
  <p>So I am trying to make a new function in google sheets in which <code>newNum()</code> will take any number and add it to the previous (global) num.</p>
  
  <p>i.e.
  <code>newNum(1)</code> will print <code>2</code>.<br>
  <code>newNum(5)</code> will now print <code>7</code>.<br>
  <code>newNum(3)</code> will now print <code>10</code> and so on.</p>
  
  <p>Thank you everyone in advance!</p>