I am trying to place my _rows values into my object value , however i have tried running a loop but i wasnt able to get the data out , the script i used is
let _columns = ["Name", "age", "phone"]
let _rows = [[{ value: 'john' }, { value: '22' }, { value: '999' }], [{ value: 'Bob' }, { value: '21' }, { value: '222' }]]
let res = {}
for (let i = 0; i < _rows.length; i++) {
for (let a = 0; a < _columns.length; a++) {
console.log(_rows[i][a].value)
}
res = _columns.reduce((acc,curr)=> (acc[curr]="data",acc),{});
console.log(res)
res = {}
}
on my console.log , it prints
The target output should be
{Name: 'john', age: '22', phone: '999'}
{Name: 'bob', age: '21', phone: '222'}

const obj = {name: 'abc', age: '20'};. And I need to add anotherprop/keyto this object but the name of that prop is stored in a variable like so:let propName = 'id';and the corresponding value is'0'. Then, if one uses:obj[propName] = '0', the objectobjbecomes like so:{name: 'abc', age: '20', id: '0'}.acc[curr]="data"the string"data"is being assigned to every column of every row. It is my understanding that, that is why one gets that on theconsole.log.