title: Using Reduce method
body: <p>I just started learning about reduce method, and stuck in this problem...</p>
  <pre><code>  N   answer
  123   6
  987   24
  </code></pre>
  <p>An example would be 9 + 8 + 7 = 24 but the parameter is in number.</p>
  <p>Here is what I have tried:</p>
  <pre><code>function solution (n){
     let result = new Array (n)
     let answer = result.reduce((a,b) =&gt; {
         return a + b 
     })
  }
  </code></pre>
  <p>Here is my code but I'm getting <code>TypeError [Error]: Reduce of empty array with no initial value</code></p>