title: Javascript - Sum of few numbers in array with reduce() or some other built-in method
body: <p>So I was wondering, if there is a <strong>shorter or different way to get the sum of FEW numbers in an array</strong>, not the complete array.
  For example if i want to get the sum of first 3 numbers in array, I know I can go trough loop like this:</p>
  
  <pre><code>var arr=[1,2,3,4,5];
  var sum=0;
  for(var i=0; i&lt;3;i++){
  sum+= arr[i];
  }
  console.log(sum);
  </code></pre>
  
  <p>But I would like to know if you can somehow use <strong>reduce()</strong> method? Or even <strong>some other built-in method</strong>?
  I tried reduce like this,few times on my own, but it isn't working:</p>
  
  <pre><code>var arr= [1,2,3,4,5];
  arr.reduce(function(total,amount,index){
  total+=amount;
  if(index===2){
  return total;
  }
  });
  </code></pre>