Function Declaration

Take a look at the syntax below:

function functionName() {
    console.log('Hello World!');
}

functionName();
  • function keyword is used to declare a function which is followed by a function name with parentheses functionName()

  • than we can put in multiple instructions inside the block

  • In the last line we call the declared function by its function name functionName()

Some other examples:

function getReminder() {
  console.log('Water the plants.');
}

function greetInSpanish() {
  console.log('Buenas Tardes.');
}

Last updated