Automation using nodered &&/if/else

Hi i’m trying to create a function to operate my fish tank pump.

Basically i’m trying to make a simple function that will only turn the pump on if the leak sensor is “off” (dry). I’m just not familiar with the formatting and syntax,

So this what i’m trying:
notes: msg.payload is a boolean switch I have setup.

var leaktest = binary_sensor.fish_tank_water_sensor

if (msg.payload == “on” && leaktest == “off”) {
return “on”;
}
else {
return “off”;
}

I recommend using the switch node, use this to get you started:

https://cookbook.nodered.org/basic/

thanks HyonoToad,
I don’t see an example there that will assist unless I’m missing something.

found another way of doing it. I created a multi input boolean sensor, then used that in node red