Travis build: 1751 [cron]

This commit is contained in:
30secondsofcode
2018-02-26 20:28:33 +00:00
parent 5fd3f348dc
commit 76b2582c8e
8 changed files with 2062 additions and 1920 deletions

View File

@ -2,9 +2,9 @@ const sortedLastIndexBy = (arr, n, fn) => {
const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);
const val = fn(n);
const index = arr
.map((val, i) => [i, fn(val)])
.map(fn)
.reverse()
.findIndex(el => (isDescending ? val <= el[1] : val >= el[1]));
.findIndex(el => (isDescending ? val <= el : val >= el));
return index === -1 ? 0 : arr.length - index;
};
module.exports = sortedLastIndexBy;