JavaScript: Array.reduceRight