How to compare 2 sets of data for mismatch values?

I’m new to d3js and I’m struggling to find a way to do the following:

Given the data below:

data = ({
  Value1: ["U", "U", "U--", "V", "W", "W--", "X", "Y"],
  Value2: ["u", "u--", "u", "v", "w", "w", "x", "y"]
})
truth_data = ({
  Value1: ["U", "V", "W", "X", "Y"],
  Value2: ["u", "v", "w", "x", "y"]
})

data:

Value1 Value2
U u
U u–
U– u
V v
W w
W– w
X x
Y y

truth_data:

Value1 Value2
U u
V v
W w
X x
Y y

Will it be possible using d3js to create the resulting data set like below?

data_issues:

Value1 Value2 Issues
U u
U u– Value2
U– u Value1
V v
W w
W– w Value1
X x
Y y

Where the values that don’t match against the truth_data are flagged in an issues column?

here’s a solution in vanilla javascript

I hope you can extend it to your actual use case

Hi Fil,

Thank you for taking the time, but your recursive solution is not the easiest for me to digest. It does work like a charm!

I manage to do it using _.differenceWith(data.Value1, truth_data.Value1, _.isEqual) from lodash