I am wondering how to pass a variable between 2 functions.
I have looked on Stackoverflow but all examples I tried did not work for me.
I have function, which calculates an array: arrR
.
Now, I would like to call this variable somewhere else:
function my_function(arrR) {
return(arrR[1]);
}
function onRefresh(chart) {
chart.config.data.datasets.forEach(function(dataset) {
dataset.data.push({
x: Date.now(),
y: myfunction(arrR)
});
});
}
But y: myfunction(arrR)
gives notting. I have checked that if I put some number say y: 1
this works.
Any clue ?
Many thanks