0
0
Node.jsframework~20 mins

REPL for interactive exploration in Node.js - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Node.js REPL Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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;
A15
Bundefined
CNaN
DSyntaxError
Attempts:
2 left
💡 Hint
Remember that the REPL evaluates expressions and shows their result.
component_behavior
intermediate
2: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;
ASyntaxError
BReferenceError: x is not defined
Cundefined
D42
Attempts:
2 left
💡 Hint
In REPL, assigning without declaration creates a global variable.
📝 Syntax
advanced
2: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?
Aconst x = ;
Bfunction test() { return 1; }
Clet y = 5;
Dconsole.log('Hello');
Attempts:
2 left
💡 Hint
Look for incomplete or invalid syntax.
🔧 Debug
advanced
2: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;
ABecause the REPL does not support let declarations
BBecause console.log is not defined in REPL
CBecause myVar is used before declaration and let does not hoist initialization
DBecause myVar is declared with let and cannot be logged
Attempts:
2 left
💡 Hint
Think about variable hoisting and temporal dead zone.
🧠 Conceptual
expert
2:00remaining
What is the purpose of the underscore (_) variable in Node.js REPL?
In the Node.js REPL, what does the underscore (_) variable represent?
AIt is used to clear the REPL screen
BIt stores the result of the last evaluated expression
CIt is a special variable for declaring constants
DIt holds the current working directory path
Attempts:
2 left
💡 Hint
Try evaluating expressions and then typing _ to see what it holds.