【发布时间】:2016-07-11 19:32:08
【问题描述】:
我没有灵感了,我必须做的事情可能很简单,但 idk。
假设我们有这个数组:
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: ....
}
]
所以我需要的问题数组是另一个这样的数组:
var array = [
{
name: 'Name1',
overall_score: --total score-- if the correct_ans is y
score: [
{
score: 5,
challenge: ....
}
]
}
]
等等.. 基本上我想从答案表中创建一个排行榜。 我设法提取对象而不重复它们我不确定这是否对我有帮助:https://plnkr.co/edit/rXRrPc1MrSs181GBv8tf?p=preview
【问题讨论】:
-
是的,但据我所知,有很多我不明白的东西。但是感谢您提供的链接,它可能会在未来有所帮助。
标签: javascript arrays html oop