Skip to content
Subhajit Sahu edited this page Jun 17, 2020 · 13 revisions

Finds largest entry. 🏃 [:vhs:] 📦 🌔 📒

Similar: min, max, range.

entries.max(x, [fc], [fm]);
// x:  entries
// fc: compare function (a, b)
// fm: map function (v, k, x)
const entries = require('extra-entries');

var x = [['a', 1], ['b', 2], ['c', -3], ['d', -4]];
entries.max(x);
// [ 'b', 2 ]

entries.max(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 'd', -4 ]

entries.max(x, null, v => Math.abs(v));
// [ 'd', -4 ]

references

Clone this wiki locally