I am attempting to extract the values from arrayOne
that do not appear in both groups within arrayTwo
. In the example below, I am looking to identify b
and d
for group1
and a
and b
for group2
.
arrayOne = ['a','b','c','d']
arrayTwo = [{
group1:[['a', 4],['c',8]],
group2:[['c', 7],['d',11]]
}]
I have experimented with various methods so far, but I am struggling to maintain the correct order. This is my current attempt:
arrayTwo[0].group1.forEach(e => {
console.log(e)
arrayOne.forEach(f => {
if(e[0] != f) {
console.log(e[0])
}
})
})
Expected outcome
b
d