Adding parameters to a function

Parameters are used to import values from outside the function and they are set on the first line of the function in between parentheses.

function MyFirstFunction (variable1,variable2)


  • A function can have as few or as many parameters as you wish.
  • Not all parameters have to be used but they have to be separated by comma.
  • Any value brought in as parameter becomes a variable within the function.
  • You can use the parameters assigned to a function as any other variable.
function MyFirstFunction (MyMotorbike, MyCity) {
    document.write("I ride my " + MyMotorbike + " in " + MyCity);

Leave a Reply