JavaScript program that removes all elements from the initial array that are of the same value as the following arguments
Posted by SceDev
Last Updated: March 10, 2024

Write a JavaScript program that removes all elements from the initial array that are of the same value as the following arguments.

Code:

function removeElementsWithValue(arr, ...valsToRemove) {
    return arr.filter(el => !valsToRemove.includes(el));
  }

var result = removeElementsWithValue([1, 2, 3, 5, 2, 3, 7, 9, 8], 1, 3);
console.log(result);