Try it here
Writing first Function in JavaScript

JavaScript Functions


A function is a block of code designed to perform a particular task.

JavaScript function

A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().

Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).

The parentheses may include parameter names separated by commas:
(parameter1, parameter2, ...)

The code to be executed, by the function, is placed inside curly brackets: {}


function funName(parameter1, parameter2, parameter3)
 // code to be executed


function funName(arg1,arg2)
 var r;
 r = arg1 + arg2; //Actions
 return r; //The function returns sum of arguments

See also Writing Your First JavaScript Program

Writer profile pic

Admin on Nov 26, 2019 at 12:11 am

If you like and would like to contribute, you can write your article here or mail your article to . See your article appearing on the main page and help others to learn.

Post Comment

Comments( 0)




Forgot Password

Please enter your email address below and we will send you information to change your password.