To access material, start machines and answer questions login.
The purpose of this room is to give you an idea about one popular programming language: JavaScript. It is almost certain that you have come across the name JavaScript; however, throughout this room, we assume that you have never studied or written programs in this language.
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:
- The computer secretly picks a number between 1 and 20.
- The user keeps guessing until they get it right.
- The computer tells the user whether their guess is too low or too high.
An example session running the program is shown below.
ubuntu@tryhackme:~/JavaScript-Demo$ node guess_v3.js
I'm thinking of a number between 1 and 20
Take a guess: 10
Too high, try again.
Take a guess: 5
Too low, try again.
Take a guess: 7
You got it in 3 tries!
We will try to follow an approach similar to the one we followed in the Python: Simple Demo room. Hence, we chose the same idea to implement. The reason for this is to allow you to explore the main language differences for the same program idea.
Learning Objectives
- Learn about JavaScript variables
- Understand how conditional statements are used
- See iteration (loop) in action
Prerequisites
I am ready to build this game in JavaScript!
Ready to learn Cyber Security?
The JavaScript: Simple Demo room is only available for premium users. Signup now to access more than 500 free rooms and learn cyber security through a fun, interactive learning environment.
Already have an account? Log in
