get smallest value in array js 1

get smallest value in array js

const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = Math.min(...arr)
console.log(min)

Here is what the above code is Doing:
1. We’re using the spread operator to spread the array into individual arguments.
2. We’re passing those arguments to the Math.min() function.
3. The Math.min() function returns the minimum value.

Similar Posts