Your code looks ok to me, can you share what error you get?
Here is what worked for me:
function greet(name="NULL")
{
        if(name!="NULL")
        {
                console.log("Hello "+name+"! Thanks for joining us.");
        }
        else {
                console.log("What is your name?");
        }
}
// call the function
greet("Abhishek");