0
0
Javascriptprogramming~20 mins

Running JavaScript using Node.js - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Node.js Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:00remaining
Output of a simple Node.js script
What is the output when running this Node.js script?
Javascript
console.log('Hello from Node.js!');
AReferenceError
Bundefined
CSyntaxError
DHello from Node.js!
Attempts:
2 left
💡 Hint
Look at what console.log prints to the terminal.
Predict Output
intermediate
1:30remaining
Understanding asynchronous behavior in Node.js
What will be the output order when running this Node.js code?
Javascript
console.log('Start');
setTimeout(() => console.log('Timeout'), 0);
console.log('End');
A
End
Start
Timeout
B
Start
End
Timeout
C
Timeout
Start
End
D
Start
Timeout
End
Attempts:
2 left
💡 Hint
setTimeout with 0 delay runs after the current call stack is empty.
Predict Output
advanced
1:30remaining
Output of a Node.js script using process.argv
What will be the output if you run this script with: node script.js hello world?
Javascript
console.log(process.argv.slice(2));
A["hello", "world"]
B["node", "script.js", "hello", "world"]
CSyntaxError
Dundefined
Attempts:
2 left
💡 Hint
process.argv contains command line arguments; slice(2) skips the first two.
Predict Output
advanced
1:30remaining
Error type when requiring a non-existent module
What error will Node.js throw when running this code?
Javascript
require('nonexistent-module');
AError: Cannot find module 'nonexistent-module'
BReferenceError: require is not defined
CTypeError: require is not a function
DSyntaxError: Unexpected token
Attempts:
2 left
💡 Hint
Node.js throws an error if a required module is missing.
Predict Output
expert
2:00remaining
Output of a Node.js script using top-level await
What will this script output when run with Node.js 20+?
Javascript
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));

await wait(100);
console.log('Done waiting');
AReferenceError: wait is not defined
BSyntaxError: await is only valid in async function
CDone waiting
DTypeError: wait is not a function
Attempts:
2 left
💡 Hint
Node.js 20+ supports top-level await in modules.