There is more concise version of arrayMax
function arrayMax(arr) { if(arr.length == 1) { return arr[0]; }
const pivot = arr.length/2;
const left = arrayMax(arr.slice(0, pivot)); const right = arrayMax(arr.slice(pivot));
return left > right ? left : right}
There is more concise version of arrayMax
function arrayMax(arr) {
if(arr.length == 1) {
return arr[0];
}
const pivot = arr.length/2;
const left = arrayMax(arr.slice(0, pivot));
const right = arrayMax(arr.slice(pivot));
return left > right ? left : right
}