Today you will learn:
let, const, and varBy the end, you will be able to store and use data in JavaScript.
Variables are used to store data.
let name = "John";
let age = 25;
let → can be changedconst → cannot be changedvar → older way (avoid using it)
let city = "Berlin";
city = "Hamburg"; // allowed
const country = "Germany";
// country = "France"; // error
let name = "Alice";
let age = 25;
let isStudent = true;
You can combine variables in output:
let name = "John";
let age = 25;
console.log(name + " is " + age + " years old");
let name = "John";
let age = 25;
let isStudent = true;
console.log(name + " is " + age + " years old.");
Create 3 variables about yourself and print them in one sentence.
Example:
let name = "Alex";
let age = 18;
let hobby = "gaming";
console.log("My name is " + name + ", I am " + age + " years old and I like " + hobby + ".");