I have two arrangements this way
array1=[{fecha:"2017-01-01", valor:12}, {fecha:"2017-01-02", valor:3 }];
array2 = [{fecha:"2017-01-01", valor:10}, {fecha:"2017-01-03", valor:15 }];
and I want to form a third arrangement from these two by storing the values, as long as the date coincides, so that it looks like this:
array3 = [{fecha:"2017-01-01", valor1:12, valor2:10}, {fecha:"2017-01-02", valor1:3, valor2:0}];
I tried to do it this way:
for (var j in array1.rows){
var param = array1.rows[j].key;
// console.log("disparando");
// console.log(item.key);
function locate (array) {
return array.key =param;
}
array3.push({
"y":param,
"a":array1.rows[j].value,
"b":array2.rows.find(locate).value,
});
}
but I do not get the value it remains the same in the whole array, how can I form the third fix