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
Learn

Let's break down the code we just ran:

function sayHello() { console.log('Hello, my name is Jon'); } sayHello();
  1. We started with the JavaScript keyword function, which declares the function.
  2. Next, we named the function sayHello.
  3. sayHello is immediately followed by (). We will learn about these parentheses in the next exercise. They will allow us to customize the code inside the function.
  4. Then we have a block, which is denoted by {}. Just like if/else statements, the code the function will execute is wrapped by {}.

To get the function to run, we have to call it. Calling a function means you tell the function to run.

We can call this function by writing its name, followed by parentheses, like this: sayHello().

In the code above, we defined a function called sayHello on lines 1 through 3, then we called it on the last line (line 5).

How can we use functions to create a robot that can tell you when a pizza is ready?

Report a Bug
If you see a bug or any other issue with this page, please report it here.