-
Notifications
You must be signed in to change notification settings - Fork 5
count
wolfram77 edited this page Mar 25, 2020
·
30 revisions
Counts occurrences of a value.
array.count(x, v, [fn]);
// x: an array
// v: value
// fn: compare function (a, b)
// --> occurrences
const array = require('extra-array');
var x = [1, 1, 2, 2, 4];
array.count(x, 2);
// 2 ^ ^
var x = [1, 1, 2, 2, 4];
array.count(x, 3, (a, b) => a < b? 0:1);
// 4 ^ ^ ^ ^