Hello, everyone. I’m trying to figure out how to return Math.min()
and Math.max()
inside a function. Currently, the question is asking me to return both so that the minimum and maximum of an array display at the same time (i.e [ 2, 3 , 5] //=> [2, 5]
). however I think I may be messing up because it’s only returning the minimum. Thanks!
function minMax(arr) {
var min = Math.min(...arr);
var max = Math.max(...arr);
return min, max;
// only gives me [3], need [3, 5]
}minMax([3, 4, 5])