I want to map specific properties from an array of objects into another array of objects while using a value as a key in the new object.
For example, I have this object (the syntax doesn't matter is just pseudo-code):
const obj= [
{id:1 , height: 57 ,name:'jhon' , state: 'true', time: ''},
{id:2 , height:64 ,name:'max' , state: 'true', time: ''},
{id:3 , height:62 ,name:'tim' , state: 'false', time: ''},
{id:4 , height:510 ,name:'alex' , state: 'false', time: ''},
{id:5 , height: 510 ,name:'frank' , state: 'true', time: ''}
]
And I want to make a map with the name as the key and height as the value, so it looks like this:
[
{jhon : 57},
{max : 64},
...
]
CodePudding user response: