

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Learn JavaScript
incomplete
2: Basic Variables
incomplete
3: let and const
incomplete
4: Why JavaScript?
incomplete
5: Comments
incomplete
6: Numbers in JS
incomplete
7: Numbers Review
incomplete
8: Increment and Decrement
incomplete
9: Undefined vs. Undeclared
incomplete
10: Null vs. Undefined
incomplete
11: Dynamic and Weak
incomplete
12: Same Line Declarations
incomplete
13: JavaScript's Speed
incomplete
14: Strings
incomplete
15: Template Literals
incomplete
16: Java vs. JavaScript
incomplete
17: Semi-Colons in JS
incomplete
18: String Encoding
incomplete
19: Camel Case in JS
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
var is the old way to declare variables in JavaScript. Use let when reassignment is allowed and const when it isn't:
// username can be reassigned, so we use `let`
let username = "dengar_the_bh";
username = "boba_fett";
// smsSendingLimit can't be reassigned, so we use `const`
const smsSendingLimit = 1000;
var is function-scoped, so a variable declared inside an if block can leak outside it! let and const are block-scoped, which is always usually what you want.
The code as-is sends two birthday messages (oops) instead of a welcome message and a birthday message!