odin-default-js-exercises/04_removeFromArray/removeFromArray.js

18 lines
384 B
JavaScript

const removeFromArray = function(array, ...args) {
/*** cool fancy way ***/
// return array.filter(x => !args.includes(x))
/*** simpler way ***/
const output = [];
array.forEach((item) => {
if (!args.includes(item)) {
output.push(item);
}
})
return output;
};
// Do not edit below this line
module.exports = removeFromArray;