Function Overview

What are Functions?

  • Allows you to group a series of statements together to perform a specific task

  • Functions are used to promote “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(){
  alert('Good Morning');
};


// 2) Call (or run) the function

greeting();