Hi I have come across a strange JS/JQuery issue.
I have 2 arrays which contain a timestamp and a value. I have merged these 2 arrays together so that if the timestamp is the same in both arrays create one array with the timestamp, value1 and value2. (value1 is in the first array, value2 is in the second array)
Here is the code I have written to do this. value[0]
is the timestamp
var combinedArray = [];
$.each(data.new, function(key, value) {
combinedArray[value[0]] = [value[0], value[1]];
});
$.each(data.repeat, function(key, value) {
combinedArray[value[0]].push(value[1]);
});
If I log this to the browser it looks like so:
As you can see the combinedArray
does have multiple values so I'm not sure why the length is 0.
The reason this is an issue is because I need to loop over the combinedArray
which I currently cannot do.