I am trying to generate an object structure like so:
{nums: {500: 0, 600: 0}}
I have a function that loops and returns numbers as shown in object: 500 & 600. However,
No matter what I try to create an object structure like the above, it does not work.
This is what I have an array of object as follows :
const scores = [ {score: 500}, {variant_id: 600} ]
How can I loop through the scores array of object and get a structure like:
Number 0 in this example as a value that will be applicable to all scores.
{nums: {500: 0, 600: 0}}
What I have done is:
let filteredScores = [];
for (let i = 0; i < scores.length; i++) {
const element = scores[i];
filteredScores.push(element);
}
However, this does not lead to the desired results.
Any insights or input is much appreciated!