I have two arrays that I tried to compare and create a third
my first array:
sevenDays = ["04","05","06","07","08","09","10"];
my second array:
json[0] = [Object{day="04",value="5"}, Object { day="05",value="8"}, Object { day="09",value="9"}]
I am trying to get:
[[04,5],[05,8],[06,0],[07,0],[08,0],[09,9],[10,0]]
I tried like this
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]]