//返回每个系列名称,及每个系列一共有多少个课(lesson的总数);问题出现的环境背景及自己尝试过哪些方法相关代码constSeries=[{name:'Web',courses:[{name:'HTML',lessons:[{name:'HTMLLesson1'},{name:'HTMLLesson2'},{name:'HTMLLesson3'}]},{name:'CSS',lessons:[{name:'CSSLesson1'},{name:'CSSLesson2'},{name:'CSSLesson3'},{name:'CSSLesson4'}]},{name:'JavaScript',lessons:[{name:'JavaScriptLesson1'},{name:'JavaScriptLesson2'}]}]},{name:'PHP',courses:[{name:'Linux',lessons:[{name:'LinuxLesson1'},{name:'LinuxLesson2'}]},{name:'MySQL',lessons:[{name:'MySQLLesson1'},{name:'MySQLLesson2'},{name:'MySQLLesson3'},{name:'MySQLLesson4'}]},{name:'Nginx',lessons:[{name:'NginxLesson1'},{name:'NginxLesson2'},{name:'NginxLesson3'},{name:'NginxLesson4'}]}]}]functionoutput3(Series){//...}output3(Series)题目来源及自己的思路aitschool求解答和思路
2 回答
烙印99
TA贡献1829条经验 获得超13个赞
functionoutput(arr){returnarr.map(item=>{item.lessonCount=item.courses.reduce((total,cur)=>{total+=cur.lessons.lengthreturntotal},0)deleteitem.coursesreturnitem})}
添加回答
举报
0/150
提交
取消