# Why does my or statement not work

**URL:** <https://discourse.nodered.org/t/why-does-my-or-statement-not-work/20645>\
**Category:** General\
**Created:** [20 January 2020 17:53 UTC](https://discourse.nodered.org/t/why-does-my-or-statement-not-work/20645 "2020-01-20T17:53:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvanklink](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pvanklink](https://discourse.nodered.org/u/pvanklink)\
**Post date:** [20 January 2020 17:53 UTC](https://discourse.nodered.org/t/why-does-my-or-statement-not-work/20645/1 "2020-01-20T17:53:06Z")

</div>

Why does my OR statement does not work?  
i used the spec on  
[https://www.w3schools.com/js/js\_operators.asp](https://www.w3schools.com/js/js_operators.asp)

```auto
[{"id":"5457b775.aa9b78","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"472566a8.d19fa8","type":"inject","z":"5457b775.aa9b78","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":340,"wires":[["421b72a3.913a2c"]]},{"id":"421b72a3.913a2c","type":"function","z":"5457b775.aa9b78","name":"","func":"if (msg.test === \"undefined\" || msg.test === null) \n {\n msg.test= \"created by function\";\n }\n\nreturn msg;","outputs":1,"noerr":0,"x":480,"y":340,"wires":[["cee116f6.68d138"]]},{"id":"cee116f6.68d138","type":"debug","z":"5457b775.aa9b78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":340,"wires":[]},{"id":"7b1e3e27.a8f7f","type":"function","z":"5457b775.aa9b78","name":"","func":"msg.test= \"test\";\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":400,"wires":[["421b72a3.913a2c"]]},{"id":"431ebf97.5cf1c","type":"inject","z":"5457b775.aa9b78","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":400,"wires":[["7b1e3e27.a8f7f"]]}]

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 January 2020 17:56 UTC](https://discourse.nodered.org/t/why-does-my-or-statement-not-work/20645/2 "2020-01-20T17:56:39Z")

</div>

Which or statement? Please don't just paste a flow and expect us to import it and automatically know what to look at.

If it is in a Function node, how about sharing the code from that Function node directly so we don't have to import the flow to even get started.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 January 2020 17:58 UTC](https://discourse.nodered.org/t/why-does-my-or-statement-not-work/20645/3 "2020-01-20T17:58:15Z")

</div>

Having said that... I've imported your flow...

```auto
if (msg.test === "undefined" || msg.test === null) 

```

You are testing if the property `msg.test` is equal to the string `"undefined"`. I assume you want to check if it is `undefined`. If so, then:

```auto
if (msg.test === undefined || msg.test === null) 

```

---

<div class="post-metadata">

**Author:** ![pvanklink](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pvanklink](https://discourse.nodered.org/u/pvanklink)\
**Post date:** [20 January 2020 18:33 UTC](https://discourse.nodered.org/t/why-does-my-or-statement-not-work/20645/4 "2020-01-20T18:33:42Z")

</div>

works perfect, flow finished!
