已知endorsement array, 要求寫一個function實作想要輸出的結果:
// function input
var endorsements = [
{ skill: 'javascript', user: 'Chad' },
{ skill: 'javascript', user: 'Bill' },
{ skill: 'javascript', user: 'Sue' },
{ skill: 'html', user: 'Sue' },
{ skill: 'css', user: 'Sue' },
{ skill: 'css', user: 'Bill' }
];
// function output
[
{ skill: 'javascript', user: [ 'Chad', 'Bill', 'Sue' ], count: 3 },
{ skill: 'css', user: [ 'Sue', 'Bill' ], count: 2 },
{ skill: 'html', user: [ 'Sue' ], count: 1 }
];
雷雷