I am working on a function that needs to find the maximum values for any number of arrays. The user should be able to input 1 array or up to 10 arrays, and the output should display the max values for each of these arrays.
However, at the moment, my code only functions properly when one array is provided. I need help identifying what is causing this issue.
function getMaxs(args){
array = args;
var max = array[0];
for(i = 0; i < array.length; i++){
if(max < array[i]){
max = array[i];
}
}
console.log(max);
return max;
}
getMaxs([5, 6, 7], [18, 19, 20], [5, 7, 3, 10]); // returns 7
getMaxs([5, 6, 7]); // returns 7
getMaxs([18, 19, 20], [5, 10, 74, 394]); // returns 20