Files
30-seconds-of-code/test/takeRightWhile/takeRightWhile.js
2018-10-01 20:16:38 +00:00

4 lines
140 B
JavaScript

const takeRightWhile = (arr, func) =>
arr.reduceRight((acc, el) => (func(el) ? acc : [el, ...acc]), []);
module.exports = takeRightWhile;