Extra Code

Additional JS code executed when the course is fully loaded.



Declare functions (and hook functions) :


A function is a parametric block of code defined one time and called any number of times later.


You can also define functions using the Function constructor and a function expression.


JavaScript Demo: Statement - Function



function calcRectArea(width, height) {

  return width * height;

}


console.log(calcRectArea(5, 6));

// expected output: 30



SyntaxSection


function name([param[, param,[..., param]]]) {

   [statements]

}


name


The function name.


param

The name of an argument to be passed to the function. Maximum number of arguments varies in different engines.

statements


The statements which comprise the body of the function.



Text is available under the Creative Commons Attribution-ShareAlike License