I have a JSON array that represents a list of objects (people). every object (every person) has name attribute, image, and an array of numbers.
Example:
"people":[
{
"name":"nunu",
"image":"image1",
"numbers":{
"total":50,
"vector":[
10,
20,
5,
10,
5
]
}
}
];
My goal is to update all vectors and append some calculation to each vector.
This is what I tried:
this.people = this.people.map((person) => {
return person.numbers.vector.map((num) => {
return Math.round(((num / divider) * 100) / 100);
});
});
The problem is that people is being replaced by the numbers in my vector and I lose the people data.
How I can update the vectors without making nay change to any other data?
.forEach()on the outer array, and just updateperson.numbers.vectorfor each one..map