| Lab/Room | TryHackMe - Programming basics |
|---|---|
| Type | Classroom |
| Statut | Done |
| Date | 01/03/2026 |
Explore what a basic JavaScript program looks like.
JavaScript is used in most of the web pages that you visit on a day-to-day basis. Consequently, when we think of JavaScript engines, web browsers come to mind. In fact, JavaScript was initially developed to run on client machines, in particular, within a web browser. However, this has changed with the release of Node.js, which enables developers to build web applications with JavaScript. Consequently, as Node.js spread, JavaScript was no longer just a client-side programming language but also a server-side one.
In this room, we will create a “Guess the Number” game. Our plan will be as follows:
JavaScript code can be executed in two main environments: directly inside a web browser or from the command line using Node.js. In this room, all the code is tested using Node.js, which allows us to run JavaScript outside of a browser, directly in the terminal.
To execute a JavaScript file with Node.js, we use the following command:
node demo.js
Here, demo.js represents the name of the file containing our JavaScript code. When this command is executed, Node.js reads the file and runs the instructions line by line.
If we were working in a browser instead, we would: