我有两个数组,我试图比较并创建第三个
我的第一个数组:
sevenDays = ["04","05","06","07","08","09","10"];
我的第二个数组:
json[0] = [Object{day="04",value="5"}, Object { day="05",value="8"}, Object { day="09",value="9"}]
我想要得到的是:
[[04,5],[05,8],[06,0],[07,0],[08,0],[09,9],[10,0]]
我试过这样
var desiredArray= [];
$.each(sevenDays, function (i, v) {
val= 0;
if (json[0][i].value) val = json[0][i].value;
desiredArray[i] = [v, val]
});
[[04,5],[05,8],[06,9],[07,0],[08,0],[09,0],[10,0]] //output