The Mystery Variable

Medium+20 XP

Mission Briefing

The Guild requires an anonymous magical spell that can be safely passed around in a container. You'll need to store a function inside a variable to keep it portable.

The Concept: Function Expressions

Functions don't always need a name! You can create an anonymous function and assign it directly to a variable. The variable then acts as the function. This is called a Function Expression.

The Objective

There is a variable called square.

  1. Assign an anonymous function to it that receives a parameter n.
  2. The function must return the square of n (n * n).

Constraints

    FundamentalsFunctions
    JavaScript
    Loading...
    3 Hidden

    Input Arguments

    n4

    Expected Output

    16

    Click RUN to test your solution