DEV Community

Discussion on: What’s your alternative solution? Challenge #15

Collapse
 
kholid060 profile image
Ahmad Kholid
const numbers = [-2, 33, 12, -6, -10, 25];

const maxNumber = numbers.reduce((max, num) => {
    if(num > max) max = num;

    return max
}, 0)

console.log(maxNumber) // 33