2020-03-24 如何把两个对象数组通过相同的id合并到一起?

manCount: [{manCount: 2, education: "大专"}, {manCount: 5, education: "本科"},…]

totalCount: [{teacherCount: 3, education: "大专"}, {teacherCount: 4, education: "本科"}]

womanCount: [{womenCount: 3, education: "大专"}, {womenCount: 4, education: "本科"}]

先定义一个空数组来接收

let newTotalList = [];

totalCount.forEach(item=>{

newTotalConcat.push(name:item.education)

}

newTotalConcat.forEach(ice=>{

                console.log(newTotalConcat)

                newTotalList.forEach(ice1=>{

                    if(ice.name==ice1.education){

                    ice.value=ice1.teacherTotal;

                    newMenList.forEach(ice2=>{

                      if(ice.name==ice2.education){

                        ice.menTotal=ice2.menTotal;

                        newWomenList.forEach(ice3=>{

                          if(ice.name==ice3.education){

                           ice.womenTotal=ice3.womenTotal;

                          }

                        })

                      }

                    })

                  }

                })

              });

你可能感兴趣的:(2020-03-24 如何把两个对象数组通过相同的id合并到一起?)