Creating Function
We have few simple statements here :
var a = 5;
var b = 10;
var c = 20;
var d = a + b + c;
alert("The value of d is: " + d);
Now, we will try convert it to function.
function myFunction() {
var a = 5;
var b = 10;
var c = 20;
var d = a + b + c;
alert("The value of d is: " + d);
}
Now we have function called 'myFunction', and it has no parameter. Your program will not execute this program unless you call it. And you can do that by writing the name of the function.
//calling function
myFunction();