Hi, I need some help!
I have an array with many numeric values that go into a function node. I only want to pass a few of these and create a new reduced array. Do you have any tips on how to do this in the best way?
Kind regards
Håkan Bodin
Hi, I need some help!
I have an array with many numeric values that go into a function node. I only want to pass a few of these and create a new reduced array. Do you have any tips on how to do this in the best way?
Kind regards
Håkan Bodin
// Get elements from index 5 to 15
const reducedArray = msg.payload.slice(5, 16); // slice(start, end) - end is exclusive
// Or get first 10 elements
const reducedArray = msg.payload.slice(0, 10);
msg.payload = reducedArray;
return msg;
try this