Function Overview

What are Functions?

  • Functions are the main “building blocks” of the program; they allow the code to be called many times without repetition

  • One of the main advantages of functions is code reuse

  • You can control when functions are executed, for example - you can write functions that only get executed (or called) when a user clicks a specific button

// a simple function that greets you with a 'Good Morning' alert

// 1) Declare a function named greeting

function greeting(){
  console('Good Morning')
}


// 2) Call (or run) the function

greeting()