Defining Functions

Defining a Function

inline

  • A function definition is code that stipulates what the function can do

  • Use the function keyword to define a function

  • Functions can be given a name

  • The name must be followed by parentheses

  • The opening and closing curly braces indicate a “code block”

  • The statements for your function goes within the code block

  • Simply defining the function will not run this code, this function must be “called” in order for the code inside the function to be run

  • Also referred to as “declaring a function”


// define a function named sayGoodMorning()
function sayGoodMorning() {
  console.log("Good Morning");
}