Let me explain my problem.
I have data like :
data: {
carType: {key: 'sport', label: 'Sports Car'},
carStyle: {key: 'striped', label: 'Striped (with blabla)'},
carPrice: {key: 'expensive', label: 'Above 500.000$'},
carOptions: [
{key: 'aluminium', label: 'Chrome Wheel (Available different size)'},
{key: 'leatherSeat', label: 'Seat Leather from Italy'},
]
}
I would need to process this data in order to get the key-values associated with my object key/// The tricky case i'm facing here, is in the case of the multiple choice.
Something like :
body: {
carType: 'sport',
carStyle: 'striped',
carPrice: 'expensive',
carOptions: ['aluminium', 'leatherSeat']
}
I did something quite verbose in ES5. I'd like, if possible, something cleaner to use with the ES6/ES7 feature to solve this. Thanks for your time.
ps: Do not take in account the content of the data. It was made up for this topic. Only the data structure cannot be modified in my case.
maporreduceover the array ofObject.keysand do the extraction in the callback function.... single key: obvious, array of objects: anothermaporreduceon the inner array.