Say we have an array:
var antibiotics = [{
bacteria: "Mycobacterium tuberculosis",
penicillin: 800,
streptomycin: 5,
neomycin: 2,
gram: "negative"
}, {
bacteria: "Salmonella schottmuelleri",
penicillin: 10,
streptomycin: 0.8,
neomycin: 0.09,
gram: "negative"
}, {
bacteria: "Proteus vulgaris",
penicillin: 3,
streptomycin: 0.1,
neomycin: 0.1,
gram: "negative"
}, {
bacteria: "Klebsiella pneumoniae",
penicillin: 850,
gram: "negative"
}];
And we want to find minand max of all numerical properties of objects in array (penicillin, streptomycin and neomycin here) assuming values can be null/absent.
How to aggregate such data from an array of objects in JavaScript?