Functions – Declaring, online

Six activities your students do on their own devices. See who's finished, and their scores.

Functions – Declaring in one minute

What students need to know

function is exactly the keyword that starts a declaration. Parentheses always follow the function name, even if empty.

function creates a named block of code you can run later. Even with no parameters, the parentheses () are required.

Mistakes students make

  • 'function' must be lowercase - a capital F causes an error.
  • Function names are case-sensitive - it should be sayHi(), not sayhi().
  • A function declaration needs parentheses after its name.
  • Calling a function needs parentheses: jump().
PREVIOUS · MODULE 37Spread Operator
YOU ARE HERE · MODULE 38Functions – Declaring
NEXT · MODULE 39Functions – Parameters

Discover other journeys with this module

What students will learn in this module

Every question in Module 38

Quick questions

  1. Does 'function' declare a reusable block of code?AYesBNo
  2. Does a function need parentheses after its name?ANoBYes
  3. Must 'function' be written in lowercase?AYesBNo
  4. Does calling a function require parentheses after its name?ANoBYes
  5. Are JavaScript function names case-sensitive?AYesBNo

Key terms

Students type the meaning of:

  • function

Match the pairs

function greet() { ... }Match it to what it does
greet();Match it to what it does
The keyword used to declare a functionMatch it to what it does
Follows a function's name in its declarationMatch it to what it does
Function greet() { console.log("Hi"); }Match it to what it does
function wave { console.log("Wave"); }Match it to what it does

Fill in the blanks

  1. ________ greet() {

    Hint: Type the keyword that declares a function.

  2. function greet_) {

    Hint: Type the opening symbol of a function's empty parentheses.

  3. ________ sayBye() {

    Hint: Type the keyword that declares a function.

  4. function sayBye_) {

    Hint: Type the opening symbol of a function's empty parentheses.

  5. greet_);

    Hint: Type the opening symbol of the parentheses that call the function.

Spot the error

Question 1

AFunction greet() {Bconsole.log("Hi");C}

Question 2

Afunction sayHi() {Bconsole.log("Hi");C}Dsayhi();

Question 3

Afunction wave {Bconsole.log("Wave");C}

Question 4

Afunction jump() {Bjump;Cconsole.log("Jump");D}

Question 5

Afunction run() {Bconsole.log("Run")C}