Beginner · 8 min
Names and values
Use const for a fixed binding and let for a value that changes.
Name a value
const declares a variable that cannot be reassigned. The equals sign assigns the value. An unquoted variable name refers to its stored value.
const city = "Ankara";
console.log(city);Output
Ankara
Change a value
Use let when you need to assign a new value later. Declare the variable once, then use its name to update it.
let tickets = 2;
tickets = 3;
console.log(tickets);Output
3
Put it into practice
- Predict the output of each example before running it.
- Complete the coding task, then try the practice questions.
Try it yourself
Code runs on this device. When you are signed in, drafts sync to your account.
Store a city
Declare city with const, assign the string "Ankara", and display city.
Assign "Ankara" to city. Display the variable without quotation marks.