我有一个Javascript的多维数组,格式如下:
[ [string, string, string, number, number], ......]
例如
[
['John', 'Apple', 'Monday', 1, 4.5],
['John', 'Orange', 'Monday', 2, 3],
['John', 'Apple', 'Monday', 1, 2.5]
]
如何按照前三项(字符串)对上述内容进行分组,并得出第一个数字的总和和第二个数字的平均值?
以上问题的答案为:
[
['John', 'Apple', 'Monday', 2, 3.5],
['John', 'Orange', 'Monday', 2, 3],
]
我以前用underscore做这个,但现在我需要只使用JavaScript或jQuery。
我找到了类似的问题(不完全相同),但没有什么帮助。