HOLLA TECH - LEARN

Multiple Parameters
 

You can define multiple parameters for a function by comma-separating them. 

function myFunc(x, y) {
   // some code
}

 

NOTE!
The example above defines the function myFunc to take two parameters.

Multiple Parameters
 

The parameters are used within the function’s definition.

function sayHello(name, age) {
  document.write( name + ” is “ + age + ” years old.”);

 

NOTE!
Function parameters are the names listed in the function definition.

Multiple Parameters [/su_quote] 

When calling the function, provide the arguments in the same order in which you defined them.

function sayHello(name, age) {
  document.write( name + ” is “ + age + ” years old.”);
}

sayHello(“John”, 20)
//Outputs “John is 20 years old.” 

 

NOTE!
If you pass more arguments than are defined, they will be assigned to an array called arguments. They can be used like this: arguments[0], arguments[1], etc.

Multiple Parameters