Math.min
and Math.max
return the minimum and maximum values. Since you want your function to print it out to the console, use console.log
to print out these values, along with a templated string to have it in the format you want.
const minAndMax = (arr) => console.log(`The minimum value in the array is: ${Math.min(...arr)}, the maximum value is ${Math.max(...arr)}`)
minAndMax([-8, -1, -87, -14, -81, -74, -20, -86, -61, -10]);
solved Find Min and Max with javascript [closed]