Last active
October 27, 2021 10:21
-
-
Save stiller/d5e41303358f8900c2f0eef39b268dec to your computer and use it in GitHub Desktop.
anna
This file contains 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
input = [ { personId: 1, color: 'red' }, { personId: 2, color: 'red' } ] | |
personIds = [...new Set(input.map(e => e.personId))] | |
//add 'green' | |
personIds.forEach(personId => input.push({ personId, color: 'green' })) | |
//remove 'green' | |
input = input.filter(item => item.color !== 'green') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment