on-internet
← Community

this function is supposed to remove specific numbers from an array, but its incomplete, it doesnt remove all numbers but rather only one

Stack Overflow ·

The function takes 2 parameters, an array and the second parameter can be a second array or a simple number. The second parameter includes numbers that should be removed from the first array. The problem I'm stuck with is that I can't seem to remove all of the numbers, I've tried many times, but I was always running into more problems. For now this is the code: const removeFromArray = function(array, remove) { let newArray = []; let itemsToRemove = remove; array.forEach(element => { if (element in itemsToRemove === false) { newArray.push(element) } }); return newArray }; console.log(removeFrom

Comments

Sign in or sign up to comment and upvote.

No comments yet.