

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
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
Like Python, Ruby, and PHP, JavaScript is a dynamically-typed (not statically-typed) language. Its variable types are only known at runtime (yes, yes, we'll talk about TypeScript in another course). Some of us like being able to see the types of our variables in our editors, okay?
Now, unlike Python, it's also weakly-typed, meaning it will automatically convert types when you do things like add a number to a string. This can lead to some unexpected behavior if you're not careful...
let answerToLife = 42;
let answerToTheUniverse = "42";
// obviously JavaScript thinks that adding strings
// and numbers is totally sane and normal behavior
const answerToEverything = answerToLife + answerToTheUniverse;
console.log(answerToEverything);
// "4242"
Run the code in its current state... Notice the very odd sum?
Well, someone introduced a bug causing Textio's message totals to be incorrect. Fix the error in the code by ensuring the value matches the correct type as you'd expect.