title: How to calculate sum of last n elements of an array using Arr.reduceRight
body: <p>I am able to calculate the sum of last n elements of an array using for loop as below. How can I achieve the same using Arr.reduceRight?</p>
  
  <pre><code>x = [1,2,3,4,5];
  y = 0
  for(let i=x.length; i&gt;x.length-3; i--) {
    console.log(x[i-1]);
    y +=x[i-1];
  
  }
  console.log(y);
  </code></pre>
  
  <p>Here is the codepen link: <a href="https://codepen.io/anon/pen/rrNxZB?editors=0011" rel="nofollow noreferrer">https://codepen.io/anon/pen/rrNxZB?editors=0011</a></p>