How to use reduce() to find min and max values with JavaScript?

To use reduce() to find min and max values with JavaScript, we use the spread operator.

For instance, we write

const min = Math.min(...items);
const max = Math.max(...items);

to call Math.min with the values in the items array spread as arguments to get the min value in the items array.

And we call Math.max with the values in the items array spread as arguments to get the max value in the items array.