i have an array of object and result object. How can i add all array's elements to result object
let result = {
list: 'example',
foo: 'something'
}
let array = [
{
item: 'a',
value: 'a',
},
{
item: 'b',
value: 'b',
},
{
item: 'c',
value: 'c',
},
]
let result = {
list: 'example',
foo: 'something',
array
}
console.log(result);
I need the result to be:
{
list: 'example',
foo: 'something',
item[0]: 'a',
value[0]: 'a',
item[1]: 'b',
value[1]: 'b',
item[2]: 'c',
value[2]: 'c'
}
How should i add an array? I'm trying something like JSON.stringify, but could'n get required format.