how to put array of numbers largest to smallest in javascript 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: get largest number in array javascript
const array1 = [1, 3, 2];
Math.max(...array1);
// expected output: 3