-
Notifications
You must be signed in to change notification settings - Fork 5
findRight
wolfram77 edited this page Mar 25, 2020
·
28 revisions
Finds index of rightmost value passing the test.
Alternatives: [left], [right], [all].
array.findRight(x, fn, [ths]);
// x: an array
// fn: test function (v, i, x)
// ths: this argument
// --> index of value, -1 if not found
const array = require('extra-array');
var x = [1, 2, 3, 4, 5];
array.findRight(x, v => v % 2 == 0);
// 3 ^
var x = [1, 2, 3, 4, 5];
array.findRight(x, v => v % 2 == 1);
// 4 ^