Need help with a simple function

See this recent thread about the differences between == and ===.

It all depends on the precise value and type of msg.payload you are testing. If it is a proper boolean value (false) rather than a String ("false") then you will be able to do:

if(!msg.payload){
    msg.payload="Online"
}
else
{
    msg.payload="Offline"
}
return msg;

But it does all hinge on what the incoming msg.payload looks like - pass it to a Debug node and share the output.