Skip to the content

Hello, world

JavaScript · Unit 1: First steps

console.log() shows in the console whatever you put inside the parentheses.

The text goes inside quotes.

console.log("Hello, world");

Prints

Hello, world

Numbers go without quotes, and if you write a calculation, JavaScript does it.

With quotes everything is text and comes out exactly as you wrote it.

console.log(2 + 3);
console.log("2 + 3");

Prints

5
2 + 3

console.log() can receive several things separated by commas.

It joins them with a space.

console.log("Emma is", 17, "today");

Prints

Emma is 17 today

Exercises in this lesson

You do them in the app, which checks them on the spot and explains why.

  1. 1. Predict the output

    What does this code print?

    console.log("Hello");
    console.log("world");
  2. 2. Complete the code

    Fill in the blank so the program says hello.

    console.___("Hello, world");
  3. 3. Predict the output

    What does this code print?

    console.log("My name is Emma");
    console.log("I am 20 years old");
  4. 4. Multiple choice

    Which line shows the text Good morning?

  5. 5. Find the bug

    This program should greet Noah. Which line has the error?

    console.log("Hello");
    console.log(Noah);
  6. 6. Multiple choice

    What does this code do?

    console.log("10 + 5");
  7. 7. Predict the output

    What does this code print?

    console.log("I will", "code");
  8. 8. Complete the code

    Fill in so it prints: Apple costs 50

    console.log(___, "costs", 50);
  9. 9. Put the lines in order

    Order the lines to print the ticket. First the title, then the price and the good trip at the end.

  10. 10. Predict the output

    What does this program draw?

    console.log("********");
    console.log("*", "Hello", "*");
    console.log("********");
Do this lesson

It opens in your browser. It is free and you do not need an account to start.

See all lessons →