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().
What students will learn in this module
Every question in Module 38
Quick questions
- Does 'function' declare a reusable block of code?AYesBNo
- Does a function need parentheses after its name?ANoBYes
- Must 'function' be written in lowercase?AYesBNo
- Does calling a function require parentheses after its name?ANoBYes
- 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 doesgreet();Match it to what it doesThe keyword used to declare a functionMatch it to what it doesFollows a function's name in its declarationMatch it to what it doesFunction greet() { console.log("Hi"); }Match it to what it doesfunction wave { console.log("Wave"); }Match it to what it doesFill in the blanks
________ greet() {Hint: Type the keyword that declares a function.
function greet_) {Hint: Type the opening symbol of a function's empty parentheses.
________ sayBye() {Hint: Type the keyword that declares a function.
function sayBye_) {Hint: Type the opening symbol of a function's empty parentheses.
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}
