Beginner

Find Maximum Number using reduce()

Write a function that takes an array of numbers as input, and returns the maximum number using the method.

`findMaxNumber`

`reduce()`

Solution Walkthrough for Find Maximum Number using reduce()

Spoiler Alert!

Don't read this unless you've already solved the problem.

This implementation first checks if the input array is empty. If it is, we return , as there is no maximum number to be found in an empty array.

`undefined`

Next, we use to iterate over the array and find the maximum number. The initial value of the accumulator is set to the first element of the array . We then compare each element of the array to the current maximum using . If the current element is greater than the current maximum, we return the current element, otherwise we return the current maximum.

`reduce()`

`arr[0]`

`Math.max()`