Challenge - 5 Problems
Node.js REPL Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Node.js REPL code snippet?
Consider this code entered in the Node.js REPL. What will be the output after pressing Enter?
Node.js
const a = 5; const b = 10; a + b;
Attempts:
2 left
💡 Hint
Remember that the REPL evaluates expressions and shows their result.
✗ Incorrect
In the Node.js REPL, expressions are evaluated and their result is printed. Here, a + b equals 15.
❓ component_behavior
intermediate2:00remaining
What happens when you declare a variable without var, let, or const in Node.js REPL?
In the Node.js REPL, what is the behavior of this code snippet?
x = 42;
x;
Node.js
x = 42;
x;Attempts:
2 left
💡 Hint
In REPL, assigning without declaration creates a global variable.
✗ Incorrect
In the Node.js REPL, assigning a value to an undeclared variable creates a global variable. So x becomes 42.
📝 Syntax
advanced2:00remaining
Which option causes a SyntaxError in Node.js REPL?
Which of these code snippets will cause a SyntaxError when entered in the Node.js REPL?
Attempts:
2 left
💡 Hint
Look for incomplete or invalid syntax.
✗ Incorrect
Option A has an incomplete variable declaration 'const x = ;' which is invalid syntax and causes a SyntaxError.
🔧 Debug
advanced2:00remaining
Why does this REPL code throw a ReferenceError?
In the Node.js REPL, why does this code throw a ReferenceError?
console.log(myVar);
let myVar = 10;
Node.js
console.log(myVar);
let myVar = 10;Attempts:
2 left
💡 Hint
Think about variable hoisting and temporal dead zone.
✗ Incorrect
Variables declared with let are hoisted but not initialized, so accessing them before declaration causes ReferenceError.
🧠 Conceptual
expert2:00remaining
What is the purpose of the underscore (_) variable in Node.js REPL?
In the Node.js REPL, what does the underscore (_) variable represent?
Attempts:
2 left
💡 Hint
Try evaluating expressions and then typing _ to see what it holds.
✗ Incorrect
The underscore variable in Node.js REPL automatically stores the value of the last expression evaluated.