I have two list:- a=[1,2,3,4,5,6], b=[2,3,6]
I want to compare both list and delete the repeating items from list a Like in this case new list a will be=[1,4,5] Note:i want to view the items of list a which are not present in list b
I have two list:- a=[1,2,3,4,5,6], b=[2,3,6]
I want to compare both list and delete the repeating items from list a Like in this case new list a will be=[1,4,5] Note:i want to view the items of list a which are not present in list b
let a = [1,2,3,4,5,6];
let b = [2,3,6];
function symmetricDifference(setA, setB) {
var _difference = new Set(setA);
for (var elem of setB) {
if (_difference.has(elem)) {
_difference.delete(elem);
} else {
_difference.add(elem);
}
}
return _difference;
}
let result = symmetricDifference(new Set(a), new Set(b));
console.log( [...result])
var arr1 = [1,2,3,4,5,6];
var arr2 = [2,3,6];
var arr3 = arr1.filter(value => !arr2.includes(value));
console.log(arr3);
if you want to delete the values from arr1 then use splice function or again filter function