

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
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
The primitive undefined value represents the absence of a value... but it's not the same thing as an "undeclared" variable!
We can create an undefined variable by giving it a name, but no value:
let favoriteSandersonCharacter; // undefined
console.log(typeof favoriteSandersonCharacter); // "undefined"
However if we never create the name, it's "undeclared", and undeclared variables actually throw an error (so don't do this):
console.log(favoriteRothfussCharacter); // ReferenceError: favoriteRothfussCharacter is not defined
The worst part is that the undeclared variable error actually says "not defined"... welcome to JavaScript. 🤦♂️
As an aside, you can use const to declare a variable that is assigned to undefined, but you wouldn't be able to set its value later, so why would you want to?
const favoriteSandersonCharacter; // SyntaxError: missing = in const declaration
const favoriteSandersonCharacter = undefined; // undefined
Create the missing variables used in the console.log calls so that they are declared but undefined. Make sure the code runs without errors.