title: why return a function inside another function in javascript? is there any advantages?
body: <p>I'm new to javascript, I'm already familiar with Python, so I'm watching a freecodecamp video on YT but something they do caught my attention and there's not really an explanation on why they do it like that. Take a simple function that is assigned to a const variable, why would they declare a function inside the function and then call it instead of just using the inner one? I don't know if I'm explaining myself, this is what I mean:</p>
  <p>Case 1 (How I would do it):</p>
  <pre><code>const increment = function(num1,num2) {
      return num1 + num2
  }
  
  console.log(increment(2,3))
  </code></pre>
  <p>output: 5</p>
  <p>Case 2 (How FCC does it):</p>
  <pre><code>const increment = function(){
    return function increment2(num1,num2) {
      return num1 + num2
    }
  }()
  
  console.log(increment(1,2))
  </code></pre>
  <p>output:3</p>
  <p>I know both work, but to me they do absolutely the same so I'm not sure why do the second case? Is there something that I'm missing? Sorry if it's a dumb question, I'm really new to everything JS</p>