Convert all values in array

This is one of my first exercises with Node-RED, so please be kind :wink:
I'm creating a simple dashboard to control my Modbus devices. Currently I can see the status of a few inputs and control the state of a few outputs. Now I want to slightly optimize the design.
Modbus-Read node gives me the following input:

msg.payload : array[8]
[ false, false, false, false, false, false, false, false ]

How can I convert [at once] each and every value in the array from true to On and false to Off?
Currently I'm converting every value like {{msg.payload[5]}} with individual Change nodes which is not nice.

one option - use a function node and

give it a go.

If you get stuck, come back.

Heres a big sledgehammer clue...

1 Like

Many thanks! Working with the following code:

var data = msg.payload;
msg.payload = => x ? "On" : "Off");
return msg;

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.