find largest two numbers in array js code example
Example 1: 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
Example 2: javascript set value to the largest value in an array
//get min/max value of arrays
function getArrayMax(array){
return Math.max.apply(null, array);