function <Function Name>(<Function Params>) { <Function Body> }
function doubleIt(x) { return 2 * x; } //call function const a = doubleIt(100); //200
function computeSum(a, b) { return a + b; } //call function const sum = computeSum(10, 5); //15
function computeSum(...numbers) { let sum = 0; for (let n of numbers) { sum += n; } return sum; } //call function const sum = computeSum(1, 2, 3); //6
function getDefaultWidth() { return 10; } //call function const w = getDefaultWidth(); //10
function printValue(value) { console.log(value); } //call function printValue('Hello'); //output: Hello
function printDefaultWidth() { console.log("200"); } //call function printDefaultWidth(); //output: 200
asExpression() { const fct = function(a, b) { return a + b; }; //run it (on the var) const sum = fct(10, 5); prn(sum); //15 }
asExpression() { const fct = function(a, b) { return a + b; }; //run it (on the var) const sum = fct(10, 5); prn(sum); //15 }
function computeSum(a, b) { return a + b; } //assign to var const fct = computeSum; //run it (on the var) const sum = fct(10, 5); //15