In this example, We will pass parameter to JavaScript function and print the result based on parameter value passed. Here is the method: function greetings(f)
{ var message = ""; if(f == 1) message = "Good morning"; else if(f == 2) message = "bye bye"; return message; } See the code snippet: