Answers for "finding max in an array using filter"

0

filter max value from array typescript

//EXemple 1 : array of simple type
const array1 = [1,6,8,79,45,21,65,85,32,654];
const max1 = array1.reduce((op, item) => op = op > item ? op : item, 0);

//EXemple 1 : array of object 
const array2 = [ {id: 1, val: 60}, {id: 2, val: 2}, {id: 3, val: 89}, {id: 4, val: 78}];
const max2 = array2.reduce((op, item) => op = op > item.val ? op : item.val, 0);

console.log(max);
console.log(max2);
Posted by: Guest on January-04-2021

Code answers related to "finding max in an array using filter"

Code answers related to "Javascript"

Browse Popular Code Answers by Language