Basic understanding of return function : <p>I'm having trouble of understanding the very basic concept of returning a value in functions (JS etc).</p>

<p>Why should I use</p>

<pre><code>function add(x,y){
  result=x+y;
  return result;
}
add(5,3);
</code></pre>

<p>instead of</p>

<pre><code>var result=0;
function add(x,y){
  result=x+y;
}
add(5,3);
</code></pre>

<p>I guess it's about saving memory, isn't it?</p>
