Skip to content

Commit

Permalink
Add implementation for .eachIndex() method
Browse files Browse the repository at this point in the history
  • Loading branch information
arnellebalane authored and aldnav committed Jun 1, 2019
1 parent d98b1b1 commit bbd2e99
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions methods/eachIndex/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function eachIndex(array, callback) {
if (typeof callback !== 'function') {
throw new TypeError('Parameter "callback" must be a function.');
}

array.forEach((item, i) => callback(i));

return array;
}

0 comments on commit bbd2e99

Please sign in to comment.