let objArray = [ {value:null} , {value:null}];
let dataArray= [{0:12},{1:23}];
How can I get the data from dataArray to assign to 'value' in objArray ? I want to obtain an object array like below:
objArray = [{value:12},{value:23}];
You can do this.
let objArray = [ {value:null} , {value:null}];
let dataArray= [{0:12},{1:23}];
const result = objArray.map((item, index) => {
item.value = dataArray[index][index]
return item;
})
console.log(result);
objArray = objArray.map....
, not using the result
const.it is pretty simple. You can use assign property values of dataArray to objArray.
objArray[0].value = dataArray[0][0]; //Note: I used bracket notation instead of dot (.) notation for accessing objects in dataArray
objArray[1].value = dataArray[1][1];
You can also iterate (loop) through arrays to assign values, but let it be practice for yourself to learn.
Good luck!