Files
30-seconds-of-code/test/pullAtIndex/pullAtIndex.js
2018-01-09 06:09:49 -05:00

9 lines
241 B
JavaScript

module.exports = (arr, pullArr) => {
let removed = [];
let pulled = arr
.map((v, i) => (pullArr.includes(i) ? removed.push(v) : v))
.filter((v, i) => !pullArr.includes(i));
arr.length = 0;
pulled.forEach(v => arr.push(v));
return removed;
};