JSFiddle - React, Tailwind, and code Playground
JavaScript
let arrayExample = [{
"color": "Blue",
"size": "5M"
},
{
"color": "Yellow",
"size": "7M"
},
];
var allColors = arrayExample.map(i => i.color);
var checkIfTrue = [{
"color": "Blue"
}].some((val) => allColors.includes(val.color));
console.log(
"functional test only for color - " + checkIfTrue
);
var allSizes = arrayExample.map(i => i.size);
var checkIfDesiredTrue = [{
"color": "Blue","size":"7M"
}].some((val) => allColors.includes(val.color) && allSizes.includes(val.size));
console.log(
"condition that should return false but return true because of other element in array - " + checkIfDesiredTrue
);