I am calculating max and min value from array of integer using JavaScript but as per my code the wrong value is coming. I am explaining my code below.
const arr = [1, 2, 3, 4, 100];
const arr1 = arr.reduce((a,i) => {
let max = a > i ? a:i;
let min = a < i ? a:i;
return {max: max, min: min};
},{})
console.log(arr1);
Here I am getting both max and min value as 100. Here I need to return max and min value from array.