Skip to content

Instantly share code, notes, and snippets.

@chy4egg
Last active June 21, 2018 10:34
Show Gist options
  • Save chy4egg/bee1449b8ee1dab4776b32d4e0d6bfba to your computer and use it in GitHub Desktop.
Save chy4egg/bee1449b8ee1dab4776b32d4e0d6bfba to your computer and use it in GitHub Desktop.
Delivery types comparison example
checkAvailableConfirmTypes() {
// variables
let oldTypes = [
{id: "2",text: "operator's call", show: true},
{id: "4",text: "confirm by sms", show: true}
];
let newTypes = {
0: "2",
};
//add a new Set from newTypes
let tempSet = new Set();
for(let item in newTypes) {
tempSet.add(newTypes[item]);
}
//if oldTypes item hasn't got tempSet item.id -> show = false
oldTypes.forEach((item)=> {
!tempSet.has(item.id) ? item.show = false : item.show = true;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment