1.0.1 • Published 6 years ago
pair-foreach v1.0.1
pair-foreach
Runs an operation for each pair in an array.
Install
Install with npm:
$ npm install --save pair-foreach
Usage
const pairForEach = require("pair-foreach");
const pairs = [
[1, 10],
[2, 9],
[3, 8],
[4, 7],
[5, 6]
];
pairForEach(pairs, (elem1, elem2) => {
console.log(elem1 * elem2);
});
The first argument for pairForEach
must be an array of 2-length arrays.
The second argument must be a function with between 2 and 4 arguments. The first 2 arguments are elements, the 3rd one is the index, and the 4th one is the original array.