What is the main purpose of the Array.reduce() method?
The Array.reduce() method executes a reducer function on each element of the array, resulting in a single output value. The reducer function takes four arguments: accumulator, current value, current index, and the source array. reduce() is particularly powerful for transforming an array into any other type of value (like an object, number, or string). It's commonly used for summing numbers, concatenating strings, or building composite data structures from array data.