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
Do you know another way to do that? Please if so let me know in the comments below. ✌️😎