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

The sayHello function from the last exercise is simple, as it only outputs 'Hello, ...', to the screen. We can do more with functions though.

Functions let us specify what they return based on data that we pass into them. Just like if you put Oreos in an ice cream machine to make cookies and cream ice cream, you can pass variables into a function and the function will operate on them.

The variables we can pass into a function are called parameters.

function sayHello(firstName) { console.log('Hello, my name is ' + firstName); } sayHello('Jon');
  1. firstName is a parameter. It is a variable that can only be used inside the sayHello function's block.
  2. We tell the function what firstName is equal to when we call the function with sayHello('Jon'). In the last line of the example, we tell sayHello what firstName is when we define 'Jon' inside the function call.
  3. When the function runs, it will know that firstName equals 'Jon' and will then use that when it runs the code inside its block.
Report a Bug
If you see a bug or any other issue with this page, please report it here.