Variables allow us to store and manage data in our code. JavaScript has several types of data we can work with, like strings, numbers, and booleans.
In JavaScript, we use let
, const
, or var
to declare variables:
let age = 25;
const name = "John";
var isStudent = true;
"Hello"
or 'Hello'
).42
or 3.14
).true
or false
).
let message = "Hello, World!";
const pi = 3.14;
var isOpen = true;
console.log(message, pi, isOpen);
Declare your own variables for name
, age
, and isStudent
. Log them to the console.
Answers: const; string; true and false.