JSFiddle - React, Tailwind, and code Playground
by Nic Fontaine
JavaScript
let arr = [
{ a: 3},
{ a: 2},
{ b: "foo"},
{ a: 1}
];
const max = arr.reduce((p, c) => {
return p.a > c.a ? p : c;
});
const mathMax = Math.max(...arr.map(o => {
if (typeof o.a !== 'undefined') {
return o.a
}
}), 0);
alert(mathMax);