I am trying to find out if two required properties are found in array of objects, I need a boolean that says true if at least those items are found and false if any of them is missing, any other properties are not an issue for the boolean as long as those two required properties are there.
So I got this, but I don't know how to produce a true boolean when both files are included
const data = [
{
name: 'required1'
},
{
name: 'noRequired'
},
{
name: 'required2'
},
{
name: 'noRequired'
},
]
const required = ['required1', 'required2']
const result = data.filter(({ name }) => !required.includes(name))
console.log(result)
.as-console-wrapper { max-height: 100% !important; top: 0; }
I have tried some and every but it does not work as it has to be the two included in the array as in 'every' but not the rest in the array as in 'some'