title: Returning a variable and a function (recursion)
body: <p>When running the following script, the return value at the end of the function is 3. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function testFunction(num) {
    
    console.log(num);
    
    if (num == 0) {
      return num;
    }
    
    return num - testFunction(num - 1);
  }
  
  console.log("Final result is: " + testFunction(5));</code></pre>
  </div>
  </div>
  </p>
  
  <p>If the return statement was switched from</p>
  
  <pre><code>return num - testFunction(num - 1);
  </code></pre>
  
  <p>to </p>
  
  <pre><code>return num + testfunction(num - 1);
  </code></pre>
  
  <p>the return value at the end is 15 (5 + 4 + 3 + 2 + 1 + 0).</p>
  
  <p>How does the original return statement end up with 3?</p>