Find max and min of an array of arrays

Let's suppose that we have the following array of arrays, each of one containing a pair of values:

javascript
let ceos = [['Elon', 1971], ['Jeff', 1964], ['Bill', 1955]];

We can use the reduce() function to find max and min:

javascript
let max = ceos.reduce((acc, ceo) => acc = ceo[1] > acc[1] ? ceo : acc);
let min = ceos.reduce((acc, ceo) => acc = ceo[1] < acc[1] ? ceo : acc);

console.log(`The youngest CEO: ${max}`); // The youngest CEO: Elon, 1971
console.log(`The oldest CEO: ${min}`); // The oldest CEO: Bill, 1955

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.