【发布时间】:2018-11-22 05:40:51
【问题描述】:
这是名为 CandidateArray 的数组中的输入数据:
[
{"name":"george","languages":["php","javascript","java"],"age":19,"graduate_date":1044064800000,"phone":"32-991-511"},
{"name":"anna","languages":["java","javascript"],"age":23,"graduate_date":1391220000000,"phone":"32-991-512"},
{"name":"hailee","languages":["regex","javascript","perl","go","java"],"age":31,"graduate_date":1296525600000,"phone":"32-991-513"}
]
由于函数的原因,我需要在这个集合中进行转换:
{candidates: [
{name: "George", age: 19, phone: "32-991-511"},
{name: "Hailee", age: 31, phone: "32-991-513"},
{name: "Anna", age: 23, phone: "32-991-512"}
],
languages: [
{lang:"javascript",count:1},
{lang:"java", count:2},
{lang:"php", count:2},
{lang:"regex", count:1}
]}
函数repCandidates:
const reportCandidates = (candidatesArray) => { return repObject}
- 我需要用javascript ES6写
- 我不应该使用循环(for、while、repeat),但允许使用 foreach,如果我使用“reduce”函数会更好
- 应聘者应按毕业日期组织的姓名、年龄和电话返回。
- 应按字母顺序返回语言及其计数器。
请访问https://codepen.io/rillervincci/pen/NEyMoV?editors=0010查看我的代码。
【问题讨论】:
标签: javascript arrays json sorting collections