JSFiddle - React, Tailwind, and code Playground
by DineshAngappa
HTML
<textarea id="result"></textarea>
JavaScript
var aaa = [
{name: "AAA", id: 845},
{name: "BBB", id: 839},
{name: "CCC", id: 854}
];
var bbb = [
{id: 839, key: 'ff'},
{id: 854, key: 'gg'}
];
var ids = {};
_.each(bbb, function (bb) { ids[bb.id] = true; });
/*var out = _.filter(aaa, function(val){
return ids[val.id];
});*/
var out =_.filter(bbb, function(a){
return _.find(aaa, function(b){
return b.id === a.id;
});
});
var dnaModuleList = [{
"key": "Masterpact MTZ IEC61850",
"value": "LV850046",
"isInstalled": true
},
{
"key": "Masterpact MTZ IEC61850",
"value": "LV850013",
"isInstalled": true
},
{
"key": "Masterpact MTZ IEC61850",
"value": "LV850045",
"isInstalled": false
}]
var filtered = _.filter(dnaModuleList, function(val){
return !(val.isInstalled)
});
var newList = {};
newList.ff = filtered;
console.log(newList);
var finalDnaModuleList =[
{
name: '_WFCtriporiented_',
description: '_wfcDescription_',
benefits: '_wfcbenefit_',
refNum: 'LV850003',
dnaType: '_diagnosis_',
isVisible: true,
isInstalled: false,
Key: "WFC trip oriented",
appId: 1,
appEnumId:'WFCTripID',
isModuleVisible: true,
shareLink:'',
NovaFirmwareVersion:1
},
{
name: '_Energyperphase_',
description: '_Energyperphasedesc_',
benefits: '_energybenefit_',
refNum: 'LV850002',
dnaType: '_metering_',
isVisible: true,
isInstalled: false,
Key: "Energy per phase",
appId: 2,
appEnumId:'EnergyPhsID',
isModuleVisible: true,
shareLink:'',
NovaFirmwareVersion:1
...