JavaScript - Min and Max values from an Array of Numbers

JavaScript - Min and Max values from an Array of Numbers

You have an array of numbers and you need to know the minimum and maximum values of the array without having to traverse the entire array, don't worry about it, you can get the minimum and maximum values very quickly using the following expression:

let values = [200, 0, 1, 24, -5, 10]
const minValue  = Math.min(...values)
const maxValue = Math.max(...values) 
console.log(minValue, maxValue)

// Output --> -5 200

Screen Recording 2022-10-14 at 01.04.33.gif

Do you know another way to do that? Please if so let me know in the comments below. ✌️😎