const arr = [
'code1',
'code2',
'code3',
'code4',
'code5'
];
const data = [
{
device: 'code1'
}, {
device: 'code2'
} ];
const codeList = data.map((x: any) => x.device);
const updatedList = arr.filter((x: any) => codeList.indexOf(x) < 0);
There are two existing data objects for device codes, code1 and code2.
My goal is to make an edit on my side.
For example, I have a list of device codes from code1 to code 5.
Then, I have two data objects, with code1 and code 2 as the device codes.
When I attempt to edit the data object with code1,
The list should display only code1, and code2 should not be displayed.
It should look like this after editing code1:
[
'code1',
'code3',
'code4',
'code5'
]