Find more freelance jobs
|
some statements } Arguments are variables that will be used in the function. The variable values will be the values passed on by the function call. By placing functions in the head section of the document, you make sure that all the code in the function has been loaded before the function is called. Some functions returns a value to the calling expression function result(a,b) { c=a+b return c } How to call a function A function is not executed before it is called. You can call a function containing arguments: myfunction(argument1,argument2,etc) or without arguments: myfunction() The return statement Functions that will return a result, must use the return statement, this statement specifies the value which will be returned to where the function was called from. Say you have a function that returns the sum of two numbers: function total(a,b) { result=a+b return result } When you call this function you must send two arguments with it: sum=total(2,3) Conditionals Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. |