Javascript is a versatile programming language used for creating dynamic and interactive web content.
In JavaScript, variables are like boxes where you can store information. You can name a box, put something inside, and use it later.
let name = "Alex";
let age = 14;
let isStudent = true;
let
is a keyword to declare a variable.=
sign assigns a value.true
or false
.Variables allow you to write flexible and reusable code. For example, you can ask a user's name and greet them with it.
let userName = prompt("What's your name?");
alert("Welcome, " + userName + "!");
You can change what's inside a variable any time.
let score = 0;
score = score + 10;
Now, score
is 10!
Saving a user's high score in a game
Checking if someone is logged in or not
Variables store information, and data types tell us what kind of information it is.