JavaScript Tutorial

Reduce Function for Finding Largest

Using Array.reduce() to find the maximum value in an array.

const numbers = [1, 5, 3, 8];
numbers.reduce((max, current) => Math.max(max, current), -Infinity); // 8