I've been scratching my head for a long time with this one, even tough it feels like an easy task. I have an array with a set of objects. The array looks like this:
[ { key1: 'ok', key2: 'ok', key3: '--' },
{ key1: 'ok', key2: '--', key3: 'ok' },
{ key1: 'ok', key2: 'ok', key3: '--' } ]
I want a function that compares the objects, and returns the key that has all "ok" as it's value. In this case, I'd like it to return
key1
I've been watching Compare objects in an array for inspiration, but it just doesn't do it.
Do anyone have any suggestions? Would be a life saver
arr.reduce((s, o) => (Object.keys(o).filter(k => o[k] !== 'ok').forEach(k => s.delete(k)), s), new Set(Object.keys(arr[0])));jsfiddle.net/qemuyf3f/1