Created
July 12, 2017 05:38
-
-
Save pandauxstudio/6eaba5910fdfada75fa3f1f4c7cf6f2e to your computer and use it in GitHub Desktop.
Eliminate certain properties within an array of objects
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
// source: https://jsfiddle.net/pandauxstudio/k1nq92sk/8/ | |
// create dummy awards object array. | |
const awards = [ | |
{ | |
awardNumber: "1", | |
awardStatus: "CURRENT", | |
awardType: "CERT", | |
awardVersionNumber: 1, | |
caseId: "C11111" | |
}, | |
{ | |
awardNumber: "2", | |
awardStatus: "DRAFT", | |
awardType: "CERT", | |
awardVersionNumber: 1, | |
caseId: "C11111" | |
}, | |
]; | |
console.log('// awards'); | |
console.log(awards); | |
// iterate through awards array and print selective properties. | |
const awardsSimplified = awards.map(function(award){ | |
const awardSimplified = _.pick(award, ['awardNumber', 'awardVersionNumber']); | |
return awardSimplified; | |
}); | |
console.log('// awards simplified'); | |
console.log(awardsSimplified); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment