Create a function with 2 outputs with condition

You need to use key/value mode and make sure that the messages from the two routes have different topics. Look at what you are getting out and make sure you understand it. Then look at the Working with Messages page in the docs.

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.