I am able to achieve my goal, I split list
to be [0]
and [1]
, I am thinking maybe there is a better solution with es6? Thanks
const list = [
[
{ value: 'Apple' },
{ value: 'Banana'},
{ value: 'Orange'},
{ value: 'Grape' },
],
[
{value: 'color is Red' },
{value: 'color is Yellow'},
{value: 'color is Orange'},
{value: 'color is green'},
]]
const a = list[0];
const b = list[1];
const c = a.map(({value}, index)=>{
return {[value] : b[index].value};
})
console.log(c)
result to expect is
[
{
"Apple": "color is Red"
},
{
"Banana": "color is Yellow"
},
{
"Orange": "color is Orange"
},
{
"Grape": "color is green"
}
]