title: How to call a function that returns another function in JavaScript?
body: <p>I was taking a small test online and there was this code:</p>
  
  <pre><code>function getFunc() {
      var a = 7;
      return function(b) {
          alert(a+b);
      }
  }
  var f = getFunc();
  f(5);
  </code></pre>
  
  <p>I would like to know why I can't call <code>getFunct(5)</code> directly for example.</p>
  
  <p>I don't understand the last two lines. </p>
  
  <p>Why do I need to assign the function to a variable. What happens when doing f(5)? </p>
  
  <p>How does JS interpret that the 5 is a variable for the inner function and not the outer?</p>