let arr=[6,5,32,12];
let val=arr.reduce((res,el)=>{
console.log(res);
return res+el;
});
console.
log(
val);
// Using reduce find the max in an array
let nums = [12, 3, 4, 65, 71];
let ans = nums.reduce((max, el) => {
if (max < el) {
return el;
} else {
return max;
}
});
console.log(ans);
Comments
Post a Comment