# How to store two different ARRAY in a variable in the flow, and JOIN in a new unique array?

**URL:** <https://discourse.nodered.org/t/how-to-store-two-different-array-in-a-variable-in-the-flow-and-join-in-a-new-unique-array/70382>\
**Category:** General\
**Tags:** function-node\
**Created:** [10 November 2022 08:48 UTC](https://discourse.nodered.org/t/how-to-store-two-different-array-in-a-variable-in-the-flow-and-join-in-a-new-unique-array/70382 "2022-11-10T08:48:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lumanga](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lumanga/32/58334_2.png) [@lumanga](https://discourse.nodered.org/u/lumanga)\
**Post date:** [10 November 2022 08:48 UTC](https://discourse.nodered.org/t/how-to-store-two-different-array-in-a-variable-in-the-flow-and-join-in-a-new-unique-array/70382/1 "2022-11-10T08:48:24Z")

</div>

Dear all,  
I have a particular device, that gives me an array when I ask the value.  
I have two or more of this devices.  
How can I save/store "Array" from "A" and "B" and so on... in a "flow.set" variable or something similar, and then, in a new function node, reload the arrays and JOIN the ARRAYs to otbain a new longer array with all value? (example in the image.)  
Thanks in advance.

 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1cfed5ae2f70d38b71fc9218c4f2b517a099e56d.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 November 2022 09:51 UTC](https://discourse.nodered.org/t/how-to-store-two-different-array-in-a-variable-in-the-flow-and-join-in-a-new-unique-array/70382/2 "2022-11-10T09:51:37Z")

</div>

You could start with a `join` node to get the data in one msg. Then you can use a `change` node (using jsonata) or `function` node to concatinate the arays

Here is a simple example using the change node:

```auto
[{"id":"df0e4b16d664bfea","type":"inject","z":"fd802e9f483fc9fa","name":"base","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"BASE","payload":"[16,663,245,297,1457,45]","payloadType":"json","x":250,"y":100,"wires":[["2f3e548eca3b9ca3"]]},{"id":"ca807504efb1d5d9","type":"inject","z":"fd802e9f483fc9fa","name":"remote","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"REMOTE","payload":"[14,605,260,24,297,60]","payloadType":"json","x":250,"y":200,"wires":[["2f3e548eca3b9ca3"]]},{"id":"2f3e548eca3b9ca3","type":"join","z":"fd802e9f483fc9fa","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":450,"y":140,"wires":[["088d98afdabafa8f"]]},{"id":"66fec8013da0050e","type":"debug","z":"fd802e9f483fc9fa","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":140,"wires":[]},{"id":"088d98afdabafa8f","type":"change","z":"fd802e9f483fc9fa","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$append(payload.BASE, payload.REMOTE)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":140,"wires":[["66fec8013da0050e"]]}]

```

 ![Screen Shot 2022-11-10 at 4.50.50 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/0205b117197c2ddb4f9efaf7e6c34ced47fc0035.png)

---

<div class="post-metadata">

**Author:** ![lumanga](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lumanga/32/58334_2.png) [@lumanga](https://discourse.nodered.org/u/lumanga)\
**Post date:** [11 November 2022 08:20 UTC](https://discourse.nodered.org/t/how-to-store-two-different-array-in-a-variable-in-the-flow-and-join-in-a-new-unique-array/70382/3 "2022-11-11T08:20:25Z")

</div>

Thank you, thank you, very much!  
Issue solved!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 November 2022 08:21 UTC](https://discourse.nodered.org/t/how-to-store-two-different-array-in-a-variable-in-the-flow-and-join-in-a-new-unique-array/70382/4 "2022-11-25T08:21:24Z")

</div>

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