Learn how to get the maximum of numbers.

max function in the Math object can be used to find the maximum of multiple numbers and array.
Math.max(1,2); //2
Math.max(1,2,3); //3
If any one of the argument passed cannot be converted to number then it returns NaN
Math.max('1', 0); //1
Math.max('one', 1); // NaN
Math.max(1, 2, 3, 4, 5, 'one', 1); // NaN
We can use Math.max to find the maximum of the array
var array = [1,2,3,4,5];
Math.max(...array);
If you have array inside array you need to flatten the array then apply the max function.
To flatten an array without knowing the depth you can refer here
If you find this helpful surprise π me here.
Share if you feel happy.
Follow Javascript Jeepπ if you feel worthy.