Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor

Instead of using console.log to print our output, functions can also return their result into a variable. This enables us to write a function that performs a task and then saves the result as a variable that we can use elsewhere.

For example:

var timesFive = function (number) { return number * 5; }; console.log(timesFive(3)); // Output: 15
  1. Instead of writing function timesFive(){}, we declared a variable named timesFive, and set it equal to a function with no name. This is called an anonymous function.
  2. Inside the function, we used the keyword return, which will return the result of number * 5 into the timesFive variable.
  3. On the last line, we called timesFive(3), which invoked the timesFive function, multiplied 5 times 3, and returned the result of 15, which was then logged to the console.
Report a Bug
If you see a bug or any other issue with this page, please report it here.