1👍
I wrote a function to check for dates that are already stored in the array and it appears to be working well now.
Here is the function:
var isinArr = function(str){
for(i=0; i<DateTimeArr.length; i++){
if(str === DateTimeArr[i]){
return true;
}
}
return false;
}
And here is the updated chartUpdate() function:
function chartUpdate(params){
console.log("Querying DynamoDB");
docClient.query(params, function(err, data){
if(err) console.log(err, err.stack);
else{
data.Items.forEach(function(item){
if(!isinArr(item.DateTime.toString())){
DateTimeArr.push(item.DateTime.toString());
o2readingArr.push(item.o2percent.toString());
}
});
}
});
}
Source:stackexchange.com