Given an array of numbers, find the highest and lowest number among them.
Return an object with a min
and max
property representing the minimum and maximum values in the array.
For example:
const numbers = [13, 57, 89, 71, 12, 34, 29];
const result = findMinMax(numbers);
console.log(result); // { "min": 12, "max" 89 }
There will always be at least one number in the array.