function that takes in number array and output largest number code example
Example 1: get largest number in array javascript
const array1 = [1, 3, 2];
Math.max(...array1);
// expected output: 3
Example 2: freecodecamp basic algorithm scripting return largest numbers in arrays
function largestOfFour(arr) {
var newArr = [];
for(var i = arr.length - 1; i >= 0; i--){
arr[i].sort(function(a, b){return a - b});
newArr.push(arr[i][arr.length - 1])
}
newArr.sort(function(a, b){return -b - a});
return newArr;
}