# Compare the result of two functions and get just one

**URL:** https://discourse.nodered.org/t/compare-the-result-of-two-functions-and-get-just-one/54939
**Category:** General
**Created:** [9 December 2021 15:31 UTC](https://discourse.nodered.org/t/compare-the-result-of-two-functions-and-get-just-one/54939 "2021-12-09T15:31:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![virginiasacudato1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/virginiasacudato1/32/52205_2.png) [@virginiasacudato1](https://discourse.nodered.org/u/virginiasacudato1)
#### Post date: [9 December 2021 15:31 UTC](https://discourse.nodered.org/t/compare-the-result-of-two-functions-and-get-just-one/54939/1 "2021-12-09T15:31:08Z")

</div>

I have the result of two functions and I want to compare their result in a single function. But I can't, I don't know if it's a synchronization error or times, I tried the join node but nothing works. Here I leave some screenshots. Thanks.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/894da7c33769231584dfa7775de0b8b25ace4d57.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/4/24acda79bb6e77f2c948a74c6fbf8e599084ab5d.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [9 December 2021 16:01 UTC](https://discourse.nodered.org/t/compare-the-result-of-two-functions-and-get-just-one/54939/2 "2021-12-09T16:01:38Z")

</div>

The best way would be to put all the nodes in series and move the payload into another property of the `msg` so that it is not overwritten. Alternatively, you can use the join node to join 2 (or more) messages into one. See [this article in the cookbook](https://cookbook.nodered.org/basic/join-streams) for an example of how to join messages into one object.

---

<div class="post-metadata">

### Author: ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)
#### Post date: [9 December 2021 19:01 UTC](https://discourse.nodered.org/t/compare-the-result-of-two-functions-and-get-just-one/54939/3 "2021-12-09T19:01:10Z")

</div>

If you use function nodes you can store values of each incoming messages in the context of the function node.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [9 December 2021 21:18 UTC](https://discourse.nodered.org/t/compare-the-result-of-two-functions-and-get-just-one/54939/4 "2021-12-09T21:18:28Z")

</div>

The Join node does that for you without you having to write javascript.

---

<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: [7 February 2022 21:18 UTC](https://discourse.nodered.org/t/compare-the-result-of-two-functions-and-get-just-one/54939/5 "2022-02-07T21:18:28Z")

</div>

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