Loading
0x00Lesson 1 of 6

Your first JavaScript program

Use console.log to make a program say something.

10 min 5-question quiz 1 code exercise
By the end of this lesson you can
  • Run JavaScript code
  • Print text with console.log
  • Recognize strings and statements

JavaScript is the language that makes web pages respond to people. It also runs on servers, desktop apps and phones. Start with one instruction: console.log writes a value to the console.

hello.js
console.log("Hello, world!");
Output
Hello, world!

Text inside quotes is a string. JavaScript executes statements from top to bottom. A semicolon marks the end of a statement; JavaScript can often insert one for you, but writing it makes examples clear.

Key takeaways

  • JavaScript runs statements in order.

  • console.log(value) displays a value.

  • Put text in quotes to make a string.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write JavaScript

Write the program, run it against the test cases, and use the feedback to build your JavaScript skills.

Exercise 1

Personal greeting

+25 XP

Use the provided input string as a name. Print Hello, NAME!. If the input is empty, use friend.

  • Name provided
  • Empty input
main.js
Loading editor…

JavaScript runs in a sandboxed browser frame with a 1.5 second time limit. Input is available as the string variable input.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Did you like the lesson? 😆👍
Consider a donation to support our work: