I have this code for a class where I\'m supposed to use the reduce() method to find the min and max values in an array. However, we are required to use only a single call to
You can use array as return value:
function minMax(items) { return items.reduce( (accumulator, currentValue) => { return [ Math.min(currentValue, accumulator[0]), Math.max(currentValue, accumulator[1]) ]; }, [Number.MAX_VALUE, Number.MIN_VALUE] ); }