Last active
June 21, 2018 10:34
-
-
Save chy4egg/bee1449b8ee1dab4776b32d4e0d6bfba to your computer and use it in GitHub Desktop.
Delivery types comparison example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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