JSFiddle - React, Tailwind, and code Playground
JavaScript
Object.prototype.hasOwnPropertyCI = function(prop) {
return Object.keys(this)
.filter(function (v) {
return v.toLowerCase() === prop.toLowerCase();
}).length > 0;
};
var product = [{
"productId": 5256502,
"name": "360fly - 4K Action Camera",
"light": true,
"wiFi": true,
"colour": "Black"
}];
var _criteria = [
{
"id": 38,
"type": "Boolean",
"name": "Light",
"states": [
{
"id": 93,
"criteriaId": 38,
"name": "False"
},
{
"id": 94,
"criteriaId": 38,
"name": "True"
}
]
},
{
"id": 41,
"type": "Boolean",
"name": "New",
"states": [
{
"id": 95,
"criteriaId": 41,
"name": "True"
},
{
"id": 96,
"criteriaId": 41,
"name": "False"
}
]
},
{
"id": 42,
"type": "Boolean",
"name": "Available",
"states": [
{
"id": 97,
"criteriaId": 42,
"name": "True"
},
{
"id": 98,
"criteriaId": 42,
"name": "False"
}
]
}
];
for(var i = 0; i < _criteria.length; i++){
for(var j = 0; j < product.length; j++){
if(product[j].hasOwnProperty(_criteria[i].name.toLowerCase())){
product.splice(j,1);
_criteria.splice(i,1);
j--;
i--;
}
}
}
console.log(product);
console.log(_criteria);