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

5 lines
164 B
JavaScript

const dropRightWhile = (arr, func) => {
while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1);
return arr;
};
module.exports = dropRightWhile;