
array.reduceRight() – Similar to `reduce()` but processes the array **from right to left**.
๐ Syntax
result = array.reduceRight((accumulator, current) => {
return /* next accumulator */;
}, initialValue);
๐งช Example
const letters = ['a','b','c'];
const reversed = letters.reduceRight((acc, ch) => acc + ch, '');
console.log(reversed); // 'cba'
Comments
Post a Comment