I have 2 object arrays
const options = [
{ value: 'opt1', label: 'opt1' },
{ value: 'opt2', label: 'opt2' },
{ value: 'opt3', label: 'opt3' },
{ value: 'opt4', label: 'opt4' }
]
const selected = [
{ value: 'opt1', key: '1' },
{ value: 'opt2', key: '2' }
]
I need to compare these two arrays and get result as
result =
{ 'opt1', true },
{ 'opt2', true },
{ 'opt3', false },
{ 'opt4', false }
]
since opt1 and opt2 exists in second array. I know there are lots of methods, but what would be the shortest method?