Sorry, a lazy JS beginner coder here. Could this solution fail any test, even those not included in the algo checks?
function largestOfFour(arr) {
return (arr.length === 1) ? [Math.max(...arr[0])] : arr.map(innerArr => Math.max(...innerArr))
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
console.log(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Return Largest Numbers in Arrays
Link to the challenge: