title: Javascript anonymous function error
body: <p>I have been trying to use recursion to find the sum of a number using an anonymous function in javascript but I am getting the following error:</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected token +</p>
  </blockquote>
  
  <p>I want to use an anonymous function for this. Can anyone help me in finding what I am doing wrong here?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      console.log(function (n) {
          if (n == 0) {
              return 1;
          }
          else {
              return function(n+function(n-1));
          }
      }(8));
  &lt;/script&gt;
  </code></pre>