How to do a simple sum of two msgs which are arrays

I described how to do it. Join the arrays and use a Function node to sum them. Is that not what you want?

[{"id":"8c61ff89.907a1","type":"inject","z":"24d928f3.3c58f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":340,"wires":[["b0a5b776.cc0ec8","1d512dac.dcf892"]]},{"id":"b0a5b776.cc0ec8","type":"change","z":"24d928f3.3c58f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[1,2,3,4]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":320,"wires":[["4f2d89ed.bacd88"]]},{"id":"1d512dac.dcf892","type":"change","z":"24d928f3.3c58f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[5,6,7,8]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":360,"wires":[["4f2d89ed.bacd88"]]},{"id":"b4284113.82a9b","type":"function","z":"24d928f3.3c58f8","name":"","func":"\nvar result = [];\nmsg.payload[0].forEach(function(v,i) {\n   result.push(v+msg.payload[1][i]); \n});\nmsg.payload = result;\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":340,"wires":[["fad8c15.2e5684"]]},{"id":"fad8c15.2e5684","type":"debug","z":"24d928f3.3c58f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":340,"wires":[]},{"id":"4f2d89ed.bacd88","type":"join","z":"24d928f3.3c58f8","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":340,"wires":[["b4284113.82a9b"]]}]

(Please read this post about sharing flows on the forum: How to share code or flow json)

1 Like