get smallest value in array javascript code example
Example 1: javascript find smallest number in an array
const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = Math.min(...arr)
console.log(min)
Example 2: find smallest length string in an array js
var arr = ["aaaa", "aa", "aa", "aaaaa", "a", "aaaaaaaa"];
console.log(
arr.reduce((a, b) => a.length <= b.length ? a : b)
)