Why does my or statement not work

Why does my OR statement does not work?
i used the spec on
https://www.w3schools.com/js/js_operators.asp

[{"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"]]}]

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.

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

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:

if (msg.test === undefined || msg.test === null) 
2 Likes

works perfect, flow finished!