Files
30-seconds-of-code/test/findLastIndex/findLastIndex.js
2018-02-04 17:38:39 +02:00

6 lines
155 B
JavaScript

const findLastIndex = (arr, fn) =>
arr
.map((val, i) => [i, val])
.filter(val => fn(val[1], val[0], arr))
.slice(-1)[0][0];
module.exports = findLastIndex;