What value is obtained when executing the following code?
function maximum(arr) {
if (arr.length === 1) {
return arr[0];
}
return Math.max(arr[0], maximum(arr.slice(1)));
}
console.log(maximum([1, 5, 3, 9, 2]));
What value is obtained when executing the following code?
function maximum(arr) {
if (arr.length === 1) {
return arr[0];
}
return Math.max(arr[0], maximum(arr.slice(1)));
}
console.log(maximum([1, 5, 3, 9, 2]));