How do I search for a specific value in an array of objects based on another value? For example, I have the ID of a post and want to check if I have the required permissions for that particular Post ID.
Posts = [
{
Id: '123',
Permission: 'True',
Name: 'XY'
//Other key value pairs
},
{
Id: '456',
Permission: 'False'
Name: 'AB'
//Other key value pairs
}
];
My current approach goes in this direction.
if (posts.some(e => e.Permission === true && e.Id == PostId)) {
return true;
} else {
return false ;
}
I appreciate any support.