How can we retrieve name from the json, when array of ids are provided.
[
{
"id": 0,
"name": "salesTransNo"
},
{
"id": 1,
"name": "terminalNo"
},
{
"id": 2,
"name": "salesTransDate"
},
{
"id": 3,
"name": "salesTransTime"
},
{
"id": 4,
"name": "exceptionAmount"
},
{
"id": 5,
"name": "laneNumber"
}
]
I want to retrieve only names into an array from the JSON, when array of id values are given
eg: array of id's : [2,4,5]
Output should be:
["salesTransDate","exceptionAmount","LaneNumber"]
How can we achieve this with Lodash or with JavaScript ?
I used _.find and used _.map to pull only name from the result, but it's only working for single value, if I were to pass an array like [2,4,5] it's not working.