DEV Community

Discussion on: JavaScript Coding Challenges

Collapse
 
ramnewton profile image
Ram Newton
function destroyer(arr, ...params){
    params_set = new Set(params);
    return arr.filter(item => !(params_set.has(item)))
};
Enter fullscreen mode Exit fullscreen mode

.includes() does a linear search. Creating a set out of the parameters and using the .has() method will improve performance