# Best strategy for Switch node?

**URL:** <https://discourse.nodered.org/t/best-strategy-for-switch-node/28077>\
**Category:** General\
**Created:** [9 June 2020 18:50 UTC](https://discourse.nodered.org/t/best-strategy-for-switch-node/28077 "2020-06-09T18:50:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ad-netafy](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@ad-netafy](https://discourse.nodered.org/u/ad-netafy)\
**Post date:** [9 June 2020 18:50 UTC](https://discourse.nodered.org/t/best-strategy-for-switch-node/28077/1 "2020-06-09T18:50:11Z")

</div>

Using the switch node, I want to provide a list of specific zip codes and say "if msg.example = any of these zip codes, go out pin 1". Is this possible, and if so which strategy is best?

Am I able to say "if msg.example contains (zipcode)"-\>1 and do that for every zip code having its own output?

Or can I do it in a way that is easier to manage?

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [9 June 2020 19:02 UTC](https://discourse.nodered.org/t/best-strategy-for-switch-node/28077/2 "2020-06-09T19:02:23Z")

</div>

You could use a JSONata expression for each output / group of zip codes in the switch node by defining the zip codes inside arrays:

```auto
msg.example in ['12345', '54321']

```

---

<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:** [8 August 2020 19:02 UTC](https://discourse.nodered.org/t/best-strategy-for-switch-node/28077/3 "2020-08-08T19:02:26Z")

</div>

Closed on 8 August 2020 19:02 UTC

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