Using spread operator I can get the maximum value of two arrays using Math.max(...firstArr, ...secondArr), and get's the right value, I am trying not to add a spread operator MANUALLY, I am trying to add automatically by creating function, I am trying to add or pass a spread operator before the argument. example
var firstArr = [1,2,3,4,5];
var secondArr = [6,7,8,9];
function myFun() {
for(var i = 0; i <= arguments.length; i++) {
var resl = Math.max(...arguments[i]);
document.write("The maximum value is " + resl);
}
}
myFun(firstArr, secondArr);
It displays two result values:
The first result will be: "The maximum value is 5"
The second result will be: "The maximum value is 9"
It is not comparing two arrays at a time, Please help me. Thanks.