Reputation: 7133
My taxDetails object is carrying tax details.
Let's assume, it holds following data as for now.
taxDetails
[0] => name: praveen
amount: 100
[1]=> name: john
amount: 125
[2]=> name: eric
amount: 80
Now I need to get the record having maximum amount
var highestTax as name: john
amount: 125
I tried following two methods, but not getting
var latestTax = value.taxDetails.filter(function (el) {
return Math.max.apply(null, el.amount);
var latestTax = value.taxDetails.filter(function (el) {
return max(el.tax_year);
How can I get?
Upvotes: 1
Views: 1851
Reputation: 15213
Try:
var latestTax = taxDetails.sort(function(a,b){ return (a.amount - b.amount); }).pop();
Upvotes: 1