function
parameter
argument
return value
invoke
function getHello() {
// return the word Hello
return "Hello";
}
getHello();
//Hello
function keyword
name
body
function formatMessage(recipient,msg) {
// print the message to the console
return recipient + ' You have a message:\n ' + msg;
}
formatMessage("John", "Your appointment is at 6pm");
//John You have a message:
// Your appointment is at 6pm
function keyword
name
body
parameters
Functions are sequences of instructions that perform a specific task
Functions can be defined with parameters
Functions may return values
The values passed to function when it's invoked are called arguments