Created
February 21, 2020 07:39
-
-
Save alegut/366b1c05b6970341279880c05f3a5d6a to your computer and use it in GitHub Desktop.
Find And Replace The key-value Pair in an Array of Object
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
const personObject = [ | |
{ | |
"id":1, | |
"name": "A", | |
"experienceInYear": 5, | |
"designation" : "senior associate" | |
}, | |
{ | |
"id":2, | |
"name": "B", | |
"experienceInYear": 3, | |
"designation" : "associate" | |
}, | |
{ | |
"id":3, | |
"name": "C", | |
"experienceInYear": 6, | |
"designation" : "senior" | |
} | |
] | |
const res = personObject.map(p => p.experienceInYear >= 6 ? {...p,designation: "lead"} : p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment