Hello All
I am having a bit of trouble with some arrays within a function node. Currently I have a mysql database that returns the last 7 days worth of data. It returns it all within an array. See here
After it returns the array. I would like to take all wheel rotations and add it together. Simple right? yeah probably for most. I have done it in php but not node red.
Brushing up on my JS in the function I was trying to use the forEach seen below. it does not appear to like this https://www.w3schools.com/js/js_array_iteration.asp
here is the code I have now which is def wrong, I am used to the array [0] being at the end not the middle and I don't know what to do with it. I need to itterate through it hence the foreach but I am failing obviously
var p0 = msg.payload[0].wheel_rotations ;
p2.forEach(test);
function test(test4)
{
var test2 = test4 + test2;
}
oh myyyyyyyyyyy god that was so dang easy. I was making it 100x more complicated. I so need to learn more of this jsonata . that is EXACTLY what I need sooo easy.
I will keep this in mind for the rest of my nodes that I will be doing this to and converting some old ones.