// array which holds all values
const namesArr = ["Lily", "Roy", "John", "Jessica"];
const namesToDeleteArr = ['Roy', 'John']
const namesToDeleteSet = new Set(namesToDeleteArr);
const newArr = namesArr.filter((name) => {
return !namesToDeleteSet.has(name);
});
console.log(newArr); // ["Lily", "Jessica"]
//////////// OR //////////////////////////
function arr(integerList, valuesList){
return integerList.filter(element => {
return valuesList.indexOf(element) === -1
})
}
console.log(arr([1, 1, 2 ,3 ,1 ,2 ,3 ,4], [1, 3])) // [ 2, 2, 4 ]
//////////// OR /////////////////////////
function arr(a, valuesList){
const newArr = []
for (let i = 0; i < a.length; i++){
if (!valuesList.includes(a[i]))
newArr.push(a[i])
}
return newArr
}
console.log(arr([1, 1, 2 ,3 ,1 ,2 ,3 ,4], [1, 3]))