function findMax(arr, max = -Infinity, i = 0) { if (i > arr.length-1) return max if (arr[i] > max) { max = arr[i] } return findMax(arr,max, i +1) }
function findMax(arr) {max = -Infinityfor (i = 0; i<arr.length; i++){if (arr[i] > max) {- function findMax(arr, max = -Infinity, i = 0) {
- if (i > arr.length-1) return max
- if (arr[i] > max) {
- max = arr[i]
- }
}return max- return findMax(arr,max, i +1)
- }
function findMax(arr) { max = -Infinity for (i = 0; i<arr.length; i++){ if (Math.max(arr[i], max) > max) { max = arr[i] } } return max }
- function findMax(arr) {
arr.sort((a, b) => b - a);return arr[0]- max = -Infinity
- for (i = 0; i<arr.length; i++){
- if (Math.max(arr[i], max) > max) {
- max = arr[i]
- }
- }
- return max
- }