Review: Simple Functions
A function is a block of code that can be reused multiple times as needed. Functions may have zero or more parameters and can return values or not. In JavaScript, functions can be created using various methods, such as a function declaration or function expression.
Function Declaration:
function panda() { //do something in here
//return something (or not)
}
Function Expression:
var panda = function(){
//do something
}
var greet = function(person, greeting) {
var text = greeting + ', ' + person;
console.log(text);
};
greet('Rebecca', 'Hello');
Source: Rebecca Murphey, https://autotelicum.github.io/Smooth-CoffeeScript/literate/js-intro.html#using-functions
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified: Monday, September 11, 2023, 9:57 AM