Visualizing fundamental building blocks of code.
Statements used to create and name a variable. `let` and `const` have block scope, while `var` has function scope. `const` also prevents re-assignment.
const name = "Alice"; let age = 30; var status = "active"; age = 31; // OK name = "Bob"; // ERROR!
Observe the effects of re-assigning variables.
`const` person:
`let` score:
`var` highscore:
Statements that execute a block of code if a specified condition is true. If the condition is false, another block can be executed.
if (temperature > 25) { // 'It's hot!' } else { // 'It's a good day.' }
Enter a temperature to see the condition met.
Temperature:
Statements that execute a block of code a specified number of times, or as long as a condition is true.
for (let i = 0; i < 5; i++) { console.log(i); }
Watch the `for` loop iterate through the items.