author avatar

harshwardhan

Thu Dec 21 2017

In javascript generally if you reduce an array it starts from 0th element and goes till the end but if you want to run the reduce from right to left of an array i.e. start from last element and go till the first element use arr.reduceRight