I'm out of inspiration and probably is very simple what I have to do but idk.
Let's say we have this array :
var answers = [
{
name: 'Name 1',
score: 5,
correct_ans: 'y'
challenge: ....
},
{
name: 'Name 2',
score: 10,
correct_ans: 'n',
challenge: ....
},
{
name: 'Name 1',
score: 12,
correct_ans: 'y',
challenge: ....
},
{
name: 'Name 2',
score: 8,
correct_ans: 'y',
challenge: ....
}
]
So what I need from questions array is another array like this:
var array = [
{
name: 'Name1',
overall_score: --total score-- if the correct_ans is y
score: [
{
score: 5,
challenge: ....
}
]
}
]
And so on .. Basically I want to create a leaderboard out of a table of answers. I managed to extract the objects without repeating them I'm not sure if this help me : https://plnkr.co/edit/rXRrPc1MrSs181GBv8tf?p=preview