find smallest integer in the 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: how to find the smallest two numbers in an array javascript
function sumTwoSmallestNumbers(numbers) {
numbers = numbers.sort((a, b) => {
return a - b; });
}; //this will turn the numbers list into the 2 lowest numbers