so i have an array with all the players and one with only the one that are selected and i want to have an other array with the status if he is selected or not. i tried comparing and pushing the element with the status but didnt achieve what i wanted.
here are the arrays
const all = [
{
playerId: '294',
firstName: 'MMM',
},
{
playerId: '295',
firstName: 'arkiv',
},
{
playerId: '296',
firstName: 'julio',
},
{
playerId: '297',
firstName: 'sss',
},
];
const selected = [
{
playerId: '296',
firstName: 'julio',
},
{
playerId: '297',
firstName: 'sss',
},
];
and this is what i want to achive
const res = [
{ playerId: '294', firstName: 'MMM', status: false },
{ playerId: '295', firstName: 'arkiv', status: false },
{ playerId: '296', firstName: 'julio', status: true },
{ playerId: '297', firstName: 'sss', status: true },
];
i set up an environment to work here: https://stackblitz.com/edit/react-lkcqcd?file=src%2FApp.js
thanks for attention!