Hello, JavaScript world!
In this module, we’re going to create our very first JavaScript program. Even if you’ve never even seen code before, don't worry, we'll cover it all—from understanding what each line does to experimenting by changing the code. By the end of this lesson, you'll know how to print text to the console and understand the basics of JavaScript syntax.
Here is a piece of code that we'll start with.
// We have some code here
console.log("Hello, World!");
What Does the Code Do?
Our program uses a single JavaScript function, console.log(), to display a message. When you run your code, the message will appear in the console. This is an essential tool in JavaScript, used to output information and help debug your programs.
Breaking Down the Code
Let’s look at the code line by line.
Line 1: Comment
In JavaScript, any text following // on the same line is a comment. Comments are used to explain the code and are ignored by the computer when the program runs.
☝️ Note: Good programmers don't normally use comments to describe their code but write readable code that describes itself.
Line 2: console.log("Hello, World!");
- console.log(): This is a function call to the console.log function that prints any message inside its parentheses to the console. Functions take parameters inside the parentheses.
- "Hello, World!": This is a string—a sequence of characters enclosed in quotes. In JavaScript, strings are used to represent text.
- The semicolon ; ends a statement. We could have multiple prints on a single line like console.log(1); console.log(2); and the semicolon tells the JavaScript interpreter where one statement begins and the other ends. It's kind of like the dot in english!
- Execution: When this line runs, it tells the browser or Node.js environment to display the text "Hello, World!" in the console.
Let's practice!
Exercises
Hello World
In this exercise, your goal is to write a JavaScript program that prints "Hello, World!" to the console. Use the console.log() function in your index.ts file to output this message. After running your code, you will see the console output and the result of automated tests. Feel free to experiment by modifying the text—just remember to revert it to "Hello, World!" to pass the test.


Ready to become an ethical hacker?
Start today.
As a member of Hakatemia you get unlimited access to Hakatemia modules, exercises and tools, and you get access to the Hakatemia Discord channel where you can ask for help from both instructors and other Hakatemia members.