Functions – Return Values, online

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

Functions – Return Values in one minute

What students need to know

return is exactly the keyword that does this. This multiplies n by itself and returns the result.

return hands the value back to wherever the function was called. Once return runs, no more code in the function executes.

Mistakes students make

  • 'return' must be lowercase - a capital R causes an error.
  • 'return' is misspelled as 'retrun'.
  • This line is missing a semicolon, but that's not required in JS.
  • The block must close with }, not ].

Discover other journeys with this module

What students will learn in this module

Every question in Module 40

Quick questions

  1. Does return send a value back out of a function?AYesBNo
  2. Does return end the function's execution at that point?AYesBNo
  3. Can a returned value be stored in a variable?AYesBNo
  4. Must 'return' be written in lowercase?ANoBYes
  5. Is 'retrun' a valid spelling of the keyword?AYesBNo

Key terms

Students type the meaning of:

  • return

Match the pairs

return a + b;Match it to what it does
let total = add(2, 3);Match it to what it does
Ends a function's execution and sends back a valueMatch it to what it does
Sends back the square of a numberMatch it to what it does
Retrun a + b;Match it to what it does
Return a - b;Match it to what it does

Fill in the blanks

  1. ______ a + b;

    Hint: Type the keyword that sends a value back from the function.

  2. let total _ add(2, 3);

    Hint: Type the symbol used to assign the returned value to total.

  3. ______ x * y;

    Hint: Type the keyword that sends a value back from the function.

  4. function square(n) {
    ______ n * n;
    }

    Hint: Type the keyword that sends a value back from the function.

  5. let result _ square(4);

    Hint: Type the symbol used to assign the returned value to result.

Spot the error

Question 1

Afunction add(a, b) {BReturn a + b;C}

Question 2

Afunction sub(a, b) {Bretrun a - b;C}

Question 3

Aconsole.log("mult");Bfunction mult(x, y) {Creturn x * yD}

Question 4

Afunction square(n) {Breturn n * n;C]

Question 5

Afunction greet() {Breturn "Hi";C}Dlet msg = greet()