var activeSubjectsName = ["语文", "数学", "英语", "思想品德", "科学"];
var activeSubjectsNum = [46, 2, 2, 28, 29];
var activeSubjectsArr = [];
for (var i = 0; i < activeSubjectsName.length; i++) {
console.log(i);
var activeSubjectsObject = {};
for (var j = 0; j < activeSubjectsNum.length; j++) {
if (i == j) {
activeSubjectsObject.name = activeSubjectsName[i];
activeSubjectsObject.value = activeSubjectsNum[j];
activeSubjectsArr.push(activeSubjectsObject);
}
}
}
console.log(activeSubjectsArr);
// activeSubjectsArr=[
// {name: "语文", value: 46},
// {name: "数学", value: 2},
// {name: "英语", value: 2},
// {name: "思想品德", value: 28},
// {name: "科学", value: 29}
// ]
数组转集合
猜你喜欢
转载自blog.csdn.net/qq_36457584/article/details/82745302
今日推荐
周排行