Node.js Exercises with Answers
Practise Node.js with 143 interactive exercises: multiple choice, fill-in-the-blank, output prediction and debugging. Every exercise gives instant feedback, a hint and the full solution.
Topic All topics Introduction Modules npm & Packages File System path & os Events process & env Async Patterns HTTP Server Express Basics Express Routing Middleware REST API Validation Static Files & Templates Error Handling Streams Databases Authentication Security Testing WebSockets Processes & Workers Debugging & Performance Deployment Buffers and UTF-8 URL and URLSearchParams Integrity and Webhook HMAC HTTPS and TLS Verification DNS Resolution TCP Message Framing Compression Formats and HTTP Timers and Microtasks Fetch Bodies and Cancellation Interactive Readline CLIs Package Exports and Imports AsyncLocalStorage Request Context Web Streams Interoperability HTTP/2 Sessions and Streams Native TypeScript Type Stripping Node Permission Model Bounded File Uploads Diagnostics Channel Instrumentation
All types Fill in the blanks Multiple choice Predict the output
Any level Easy Medium Hard
Score 0 / 143
Complete the command that runs a file called app.js.
app. js
The node command runs a JavaScript file.
Check answer Show solution
Which engine does Node.js use to run JavaScript?
A SpiderMonkey B Chakra C JavaScriptCore D V8
V8 is Google Chrome's JavaScript engine.
Show answer
setTimeout ( ( ) => console . log ( 'A' ) , 0 ) ;
console . log ( 'B' ) ;
A A then B B Only A C B then A D Only B
The timer callback runs after the current script finishes.
Show answer
Which of these doesn't exist in Node.js by default?
A document B process C console D setTimeout
There's no web page, so there's no DOM.
Show answer
Why can one Node process handle many connections at once?
A It starts a thread per connection B Slow I/O is non-blocking, so the single thread keeps working while waiting C It caches every response D It runs on the GPU
The event loop runs callbacks when I/O completes.
Show answer
Complete the line to share the function with other modules.
function add ( a, b) {
return a + b;
}
export makes a value available to modules that import it.
Check answer Show solution
How do you import a default export called formatDate from './dates.js'?
A import { formatDate } from './dates.js' B require formatDate from './dates.js' C import formatDate from './dates.js' D import * from './dates.js'
Default exports are imported without braces.
Show answer
Which setting makes .js files in a project ES modules?
A "module": true in package.json B "type": "module" in package.json C "esm": "on" in package.json D A comment at the top of each file
Without it, .js files are treated as CommonJS.
Show answer
A module contains console.log('loaded') at the top level. Two other files import it in the same program. How many times is "loaded" printed?
A Zero B Twice C Once per function call D Once
Module code runs once and the result is cached.
Show answer
What replaces __dirname in an ES module?
A import.meta.dirname B process.cwd() C module.dirname D require.dirname
process.cwd() is the working directory, which can be different.
Show answer
Complete the command that runs the "dev" script.
npm dev
npm run runs any script listed in package.json.
Check answer Show solution
Which file lists a project's dependencies and scripts?
A package.json B node_modules C index.js D .npmrc
package-lock.json records exact installed versions.
Show answer
Which versions does "^2.4.1" allow?
A Only 2.4.1 B 2.4.1 and later 2.x.x versions, but not 3.0.0 C 2.4.x only D Any version
^ allows minor and patch updates within the same major version.
Show answer
Where should a test runner such as Vitest be installed?
A dependencies B globally C devDependencies D node_modules/.bin only
It's only needed during development.
Show answer
Why use npm ci instead of npm install in continuous integration?
A It installs exactly the versions in package-lock.json, giving repeatable builds B It's the only command that works there C It skips devDependencies D It updates every package
It also fails if package.json and the lock file disagree.
Show answer
Complete the line to read the file as text.
const text = await readFile ( 'poem.txt' , ' ');
The utf8 encoding returns a string instead of a Buffer.
Check answer Show solution
Which import gives you promise-based file functions?
A import { readFile } from 'node:fs/promises' B import fs from 'node:fs/sync' C import { readFile } from 'fs/async' D require('file')
fs/promises works with await.
Show answer
What does the error code ENOENT mean?
A Permission denied B The file already exists C No such file or directory D The disk is full
It's the most common file error.
Show answer
await writeFile ( 'a.txt' , 'one' ) ;
await writeFile ( 'a.txt' , 'two' ) ;
console . log ( await readFile ( 'a.txt' , 'utf8' ) ) ;
A one B two C onetwo D An error
writeFile replaces the contents each time.
Show answer
Why avoid readFileSync in a web server's request handler?
A It returns a Buffer B It blocks the event loop, so no other requests can be handled meanwhile C It can't read JSON D It's deprecated
Use the promise API with await instead.
Show answer
Complete the line to combine the folder and file name.
const file = path. ( 'data' , 'users.json' ) ;
path.join combines segments with the correct separator.
Check answer Show solution
console . log ( path. extname ( 'photo.backup.png' ) ) ;
A photo.backup.png B .png C .backup.png D png
extname returns only the last extension, with its dot.
Show answer
What's the difference between path.join and path.resolve?
A There's none B join returns an absolute path C resolve always returns an absolute path; join just combines segments D resolve only works on Windows
resolve uses the working directory when needed.
Show answer
console . log ( path. posix . join ( '/app/src' , '..' , 'public' , 'index.html' ) ) ;
A /app/src/../public/index.html B /public/index.html C app/public/index.html D /app/public/index.html
join resolves .. by removing src.
Show answer
Why use path.basename on a file name submitted by a user?
A To strip folder parts like ../ so the file can't be written outside the intended folder B To lowercase it C To add an extension D To make it absolute
This prevents path traversal attacks.
Show answer
Complete the line to trigger the 'saved' event.
store. ( 'saved' , { id: 7 } ) ;
emit triggers an event and passes arguments to its listeners.
Check answer Show solution
Which module provides EventEmitter?
A node:events B node:process C node:emitter D node:util
import { EventEmitter } from 'node:events'.
Show answer
Predict the outputmedium Events
const e = new EventEmitter ( ) ;
e. once ( 'hi' , ( ) => console . log ( 'hello' ) ) ;
e. emit ( 'hi' ) ;
e. emit ( 'hi' ) ;
A hello (once) B Nothing C hello twice D An error
A once listener is removed after it runs.
Show answer
What happens if 'error' is emitted with no error listener?
A Nothing B The error is thrown, which can crash the program C A warning is printed D The event is queued
Always listen for errors on emitters that can fail.
Show answer
Are EventEmitter listeners called synchronously or asynchronously?
A Asynchronously on the next tick B In parallel on worker threads C In random order D Synchronously, in the order they were added, before emit returns
Code after emit runs once all listeners have finished.
Show answer
Complete the line to read the PORT environment variable.
const port = Number ( process. . PORT ? ? 3000 ) ;
process.env holds environment variables.
Check answer Show solution
What type are values in process.env?
A Numbers when they look like numbers B Booleans C Strings (or undefined if not set) D Any JSON type
Convert them yourself.
Show answer
The program is run with node app.js report.csv 5. What does this print?
console . log ( process. argv . slice ( 2 ) . length ) ;
A 2 B 4 C 1 D 0
The first two entries are Node and the script.
Show answer
Which exit code means success?
A 1 B 0 C -1 D 200
Any non-zero code signals failure.
Show answer
Why listen for SIGTERM in a server?
A To restart automatically B To read environment variables C To speed up startup D To stop accepting new requests and finish current ones before exiting
This is a graceful shutdown.
Show answer
Complete the line so the function waits for the result.
const user = findUser ( 42 ) ;
await pauses the async function until the promise settles.
Check answer Show solution
What does an async function always return?
A undefined B A callback C A promise D The value directly
Returned values are wrapped in a resolved promise.
Show answer
async function f ( ) { return 5 ; }
console . log ( f ( ) instanceof Promise ) ;
A false B 5 C An error D true
Calling an async function returns a promise.
Show answer
What does Promise.all do if one of its promises rejects?
A Waits for the others and returns their results B Rejects straight away with that error C Ignores the failure D Retries it
Use allSettled to collect every outcome.
Show answer
Why process a list of 10,000 API calls in batches rather than with one Promise.all?
A Promise.all can't handle arrays that long B Batches are always faster C To keep the results in order D Starting them all at once can overload the API or database and hit rate limits
A concurrency limit protects the services you call.
Show answer
Complete the line to finish the response.
res. writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
res. ( 'OK' ) ;
res.end sends the body and completes the response.
Check answer Show solution
Which status code means "Not Found"?
A 200 B 201 C 500 D 404
404 means the server has nothing at that path.
Show answer
What does new URL(req.url, 'http://localhost').searchParams.get('page') return for /list?page=3?
A '3' as a string B 3 as a number C null D page=3
Query values are strings.
Show answer
A POST successfully creates a new item. Which status code should the server send?
A 201 B 200 C 204 D 302
201 Created, ideally with a Location header.
Show answer
Why does reading a request body need for await (const chunk of req)?
A Bodies are always compressed B The request is a stream, so the body arrives in chunks over time C JSON must be awaited D It's required for GET requests
Collect the chunks, then parse them.
Show answer
Complete the route so it handles GET requests to /about.
app. ( '/about' , ( req, res) => res. send ( 'About us' ) ) ;
app.get defines a route for GET requests.
Check answer Show solution
Where does Express put the value of :id in the route /orders/:id?
A req.query.id B req.body.id C req.id D req.params.id
Route parameters go in req.params.
Show answer
A client requests /search?q=lamp&page=2. What is typeof req.query.page?
A number B string C undefined D object
Query values are strings.
Show answer
What does app.use(express.json()) do?
A Parses JSON request bodies into req.body B Sends every response as JSON C Validates JSON D Converts query strings to JSON
Without it, req.body is undefined.
Show answer
Why should /users/me be defined before /users/:id?
A Alphabetical order is required B :id routes must come last in every file C Express uses the first matching route, and /users/:id would also match /users/me D It's faster
Put specific routes before general ones.
Show answer
Complete the line to mount the router on /orders.
app. ( '/orders' , ordersRouter) ;
app.use mounts a router or middleware on a path prefix.
Check answer Show solution
What does express.Router() create?
A A new server B A database connection C A group of routes that can be mounted on a path D A template
It's like a mini application.
Show answer
A router defines router.get('/:id', ...) and is mounted with app.use('/api/users', router). Which URL matches?
A /:id B /api/users/5 C /users/5 D /api/5
The mount prefix is added in front of the router's paths.
Show answer
What does router.route('/:id') let you do?
A Chain handlers for several methods on the same path B Create a new router C Mount a router D Validate the id
For example .get(show).put(update).delete(remove).
Show answer
Why would you use router.param('id', ...)?
A To rename a parameter B To make :id optional C To parse JSON D To run shared loading or validation code for every route that has :id
It avoids repeating the same lookup in each handler.
Show answer
Complete the middleware so the request continues to the route.
app. use ( ( req, res, next) => {
req. startedAt = Date . now ( ) ;
( ) ;
} ) ;
next passes control to the next middleware or route.
Check answer Show solution
What are the three parameters of normal Express middleware?
A req, res, next B req, res, err C app, req, res D request, response, done
Error handlers take four: err, req, res, next.
Show answer
What happens if middleware neither calls next() nor sends a response?
A Express sends 200 automatically B The next route runs anyway C Express throws an error D The request hangs until the client times out
Every request must end with a response.
Show answer
In which order are the messages printed for GET /?
app. use ( ( req, res, next) => { console . log ( 'A' ) ; next ( ) ; } ) ;
app. get ( '/' , ( req, res) => { console . log ( 'C' ) ; res. end ( ) ; } ) ;
app. use ( ( req, res, next) => { console . log ( 'B' ) ; next ( ) ; } ) ;
A A, B, C B A, C C C, A D A, C, B
The route sends a response, so the middleware added after it never runs.
Show answer
Why write requireRole('admin') as a function that returns middleware?
A Express requires it B It makes the middleware run first C It lets one piece of code create middleware configured for different roles D It's faster
This is the middleware factory pattern.
Show answer
Complete the line so a new product returns the Created status.
res. status ( ) . json ( product) ;
201 Created is the standard response to a successful POST.
Check answer Show solution
Which method and URL should fetch product 42?
A POST /getProduct?id=42 B GET /products/42 C GET /product/get/42 D FETCH /products/42
Resources use plural nouns and GET reads.
Show answer
What's the difference between PUT and PATCH?
A PUT replaces the whole resource; PATCH changes only the fields sent B They're identical C PATCH creates and PUT deletes D PUT is only for files
PATCH suits partial updates such as changing a price.
Show answer
With 23 items and limit=5, how many pages are there?
A 4 B 6 C 5 D 23
Math.ceil(23 / 5) is 5; the last page has 3 items.
Show answer
Why cap the limit query parameter at a maximum?
A To make responses prettier B Because JSON has a size limit C REST requires 50 D So a client can't request huge result sets that overload the server and database
Always protect list endpoints.
Show answer
Complete the schema so price must be a number.
const Item = z. object ( { price: z. ( ) . positive ( ) } ) ;
z.number() accepts only numbers.
Check answer Show solution
Which status code should an API return for invalid input?
A 200 B 404 C 400 D 500
400 Bad Request means the client sent something wrong.
Show answer
What's the difference between parse and safeParse in Zod?
A parse throws on invalid data; safeParse returns a result object with success B There's none C safeParse is slower D parse only works on strings
safeParse suits code that wants to build a 400 response.
Show answer
const S = z. object ( { n: z. coerce . number ( ) } ) ;
console . log ( S . parse ( { n: '42' } ) . n + 1 ) ;
A 421 B An error C 43 D '43'
coerce converts the string to the number 42 before adding.
Show answer
Why validate on the server when the browser form already validates?
A It isn't necessary B Requests can be sent directly, bypassing the browser, so only server checks can be trusted C Browsers can't validate numbers D To make the API slower
Browser validation is for convenience, not security.
Show answer
Complete the line to serve the public folder.
app. use ( express. ( path. join ( import . meta . dirname , 'public' ) ) ) ;
express.static serves the files in a folder.
Check answer Show solution
Which EJS tag outputs a value safely escaped?
A <%- value %> B <% value %> C <%= value %> D {{{ value }}}
<%- %> outputs raw HTML.
Show answer
What does res.download do?
A Downloads a file from another server B Sends a file with headers telling the browser to save it C Deletes a file D Renders a template
You can also choose the file name the user sees.
Show answer
app.use('/static', express.static('public')) is set up. Which URL returns public/img/logo.png?
A /static/img/logo.png B /img/logo.png C /public/img/logo.png D /static/public/img/logo.png
The mount path replaces the folder name in the URL.
Show answer
Why redirect with 303 after a successful form POST?
A It's faster B Browsers require it C It escapes the data D Refreshing the result page then repeats a harmless GET instead of resubmitting the form
This is the Post/Redirect/Get pattern.
Show answer
Complete the error-handling middleware's parameter list.
app. use ( ( err, req, res, ) => {
res. status ( 500 ) . json ( { error: 'Something went wrong' } ) ;
} ) ;
Error handlers must have four parameters.
Check answer Show solution
Where should the error-handling middleware be added?
A Before all routes B Inside each route C In package.json D After all routes and the 404 handler
Errors flow forward to it.
Show answer
What's an operational error?
A A bug in your code B An expected problem in a correct program, such as a missing item or a network timeout C A syntax error D A compiler warning
Programmer errors are bugs.
Show answer
try {
throw new Error ( 'outer' , { cause: new Error ( 'inner' ) } ) ;
} catch ( e) {
console . log ( e. cause . message ) ;
}
A inner B outer C undefined D An error
cause keeps the original error.
Show answer
What should an uncaughtException handler normally do?
A Log the error, then exit so a process manager can restart a clean process B Ignore the error and continue C Send the error to the client D Restart Express in place
After an unknown failure, the program's state can't be trusted.
Show answer
Complete the line to connect the streams safely.
await ( createReadStream ( 'a.txt' ) , createGzip ( ) , createWriteStream ( 'a.txt.gz' ) ) ;
pipeline connects streams and handles errors.
Check answer Show solution
What's the main benefit of streams for large files?
A They make files smaller B They encrypt data C They're synchronous D Data is processed in small chunks, so memory use stays low
Work can also start before all the data has arrived.
Show answer
Which kind of stream changes data as it passes through?
A Readable B Transform C Writable D Static
Gzip compression is a transform stream.
Show answer
Why use readline instead of splitting chunks on newlines yourself?
A It's required for text B Chunks can end in the middle of a line; readline reassembles complete lines C It's faster for small files D It removes empty lines
Hand-split chunks break lines at chunk boundaries.
Show answer
A An HTTP error B Compression overhead C When data arrives faster than the destination can handle, and the source must slow down D A memory leak
pipeline handles it automatically.
Show answer
Complete the query so the value is passed safely.
db. prepare ( 'SELECT * FROM users WHERE id = ').get(userId);
A placeholder keeps the value separate from the SQL.
Check answer Show solution
Which method returns every matching row from a prepared statement?
A get B all C run D exec
get returns the first row; run is for changes.
Show answer
A User input changing the meaning of a query because it was pasted into the SQL text B A fast way to insert rows C A database backup technique D An index type
Placeholders prevent it.
Show answer
A transaction inserts an order and then the stock update throws. After ROLLBACK, how many new orders exist?
A 1 B 2 C 0 D It depends on timing
Rollback undoes every change made since BEGIN.
Show answer
Why use a connection pool with PostgreSQL?
A Pools encrypt queries B Opening connections is slow and limited, so a pool reuses a set of open connections across requests C Pools are required for SELECT D To avoid writing SQL
pg.Pool manages this for you.
Show answer
Complete the cookie option that stops page scripts from reading the cookie.
res. cookie ( 'sid' , id, { : true , secure: true , sameSite: 'lax' } ) ;
httpOnly hides the cookie from document.cookie.
Check answer Show solution
What should a database store for each user's password?
A A salted, slow hash of the password B The password C The password encrypted with a key D The password reversed
Hashes can't be turned back into passwords.
Show answer
What's the difference between authentication and authorisation?
A They're the same B Authorisation happens first C Authentication checks who you are; authorisation checks what you're allowed to do D Authentication is only for admins
401 is about authentication; 403 is about authorisation.
Show answer
Can anyone read the payload of a JWT?
A No, it's encrypted B Yes, it's only encoded, not encrypted C Only the server D Only with the secret
The signature prevents changes, not reading.
Show answer
Why does each password hash use its own random salt?
A To make hashing faster B To encrypt the password C Salts are optional decoration D So identical passwords get different hashes and precomputed tables of common passwords don't work
The salt is stored next to the hash.
Show answer
Complete the status code for too many requests.
res. status ( ) . json ( { error: 'Slow down' } ) ;
429 Too Many Requests is the standard rate-limit response.
Check answer Show solution
Which package sets a group of protective HTTP headers in Express?
A cors B helmet C morgan D zod
It includes Content-Security-Policy and more.
Show answer
What does a path traversal attack try to do?
A Use ../ in a file name to read or write files outside the intended folder B Slow down the server C Steal cookies D Guess passwords
Check that resolved paths stay inside the folder.
Show answer
Why use execFile with an argument array instead of exec with a string?
A It's faster B exec doesn't exist C Arguments aren't interpreted by a shell, so input can't add extra commands D It runs in the browser
This prevents command injection.
Show answer
Why is cors({ origin: true, credentials: true }) dangerous?
A It disables HTTPS B It blocks all requests C It lets any website make requests with the user's cookies and read the responses D It removes security headers
Use an explicit list of trusted origins.
Show answer
Complete the check that compares two arrays by content.
assert. ( [ 1 , 2 ] , [ 1 , 2 ] ) ;
deepEqual compares objects and arrays by their contents.
Check answer Show solution
Which command runs Node's built-in test runner?
A node test B npm node-test C node --test D node run tests
It finds and runs test files automatically.
Show answer
How do you check that an async function rejects?
A assert.throws(fn) B assert.equal(await fn(), Error) C try without catch D await assert.rejects(promise)
rejects must be awaited.
Show answer
What does fn.mock.callCount() return here?
const fn = mock. fn ( ) ;
fn ( 1 ) ;
fn ( 2 ) ;
fn ( 3 ) ;
A 1 B 3 C 6 D 0
The mock records each call.
Show answer
Why pass dependencies such as a payment service into a function instead of importing them directly?
A It's faster B Imports don't work in tests C Tests can supply fakes, so code is tested without real networks, costs or delays D To use less memory
This is dependency injection.
Show answer
Complete the line to send a JSON message over the socket.
socket. ( JSON . stringify ( { type: 'hello' } ) ) ;
send transmits a message to the other side.
Check answer Show solution
What's the main advantage of WebSockets over repeated HTTP requests?
A They're encrypted by default B They don't need a server C One open connection lets both sides send messages at any time with low overhead D They only send JSON
Polling repeats full HTTP requests just to check for changes.
Show answer
Which event does a ws socket emit when a message arrives?
A data B receive C input D message
The server also emits connection for new clients.
Show answer
When are Server-Sent Events a better choice than WebSockets?
A For multiplayer games B When only the server needs to push updates, such as notifications or progress C For uploading files D Never
SSE is plain HTTP and reconnects automatically.
Show answer
Why add a heartbeat with ping and pong?
A To detect and close connections that dropped silently B To encrypt messages C To speed up messages D Browsers require it
Dead sockets otherwise linger and waste memory.
Show answer
Complete the line that sends a result from a worker back to the main thread.
parentPort. ( result) ;
postMessage sends data between threads.
Check answer Show solution
What happens to other requests while a Node server runs a long CPU-heavy loop on the main thread?
A They're handled in parallel B They're rejected C They move to another core automatically D They wait until the loop finishes
The event loop is blocked.
Show answer
Which function streams a child process's output as it's produced?
A execFile B spawn C exec D fork only
execFile collects output until the process ends.
Show answer
How does data get into a worker thread when it starts?
A The workerData option B Global variables C process.env only D It can't
Later messages use postMessage.
Show answer
Would worker threads speed up an API whose time is spent waiting on database queries?
A Yes, always B Only for POST requests C No, waiting on I/O doesn't block the event loop; workers help CPU-heavy work D Only with cluster
Measure where time goes before reaching for workers.
Show answer
Complete the line so the port comes from the environment.
app. listen ( Number ( process. env . ? ? 3000 ) ) ;
Hosting platforms provide the port in the PORT variable.
Check answer Show solution
Which command installs exactly the versions in the lock file without dev dependencies?
A npm ci --omit=dev B npm install C npm update D npm add --prod
npm ci is designed for automated installs.
Show answer
What should a readiness endpoint return while the app is shutting down?
A 200 B 404 C 302 D 503
The load balancer then stops sending new traffic.
Show answer
Why should a container run as a non-root user?
A It's faster B If the app is compromised, the attacker gets fewer permissions C Node requires it D To save disk space
This is the principle of least privilege.
Show answer
Why copy package.json and the lock file before the rest of the source in a Dockerfile?
A Docker caches the dependency install layer, so it's reused when only source code changes B npm needs them first alphabetically C It makes the image smaller D It's required by Docker
Builds become much faster.
Show answer
The worked packet contains UTF-8 é. What header length must be written?
A 2 bytes B 1 byte because there is one visible character C 4 bytes because every Unicode character uses four bytes
UTF-8 é is encoded as c3 a9, so the payload occupies two bytes.
Show answer
In the fixture, how many values does getAll("tag") return after set("q", ...)?
A Two: red and blue B One: blue because every parameter name is singular C Three because q is included in the tag array
Setting q does not alter tag; getAll selects the two pairs named tag.
Show answer
What happens when the main fixture only changes JSON whitespace while keeping the original signature?
A Verification returns false because the raw bytes changed B Verification returns true because JSON objects are equivalent C timingSafeEqual throws because JSON whitespace changes digest length
Both SHA-256 HMAC digests remain 32 bytes, but their content differs because their input bytes differ.
Show answer
Why does the complete fixture trust its self-signed demonstration certificate?
A The request explicitly supplies that certificate through ca B Every certificate naming localhost is trusted automatically C agent: false disables certificate verification
The ca option makes the fixture trust explicit; localhost and Agent selection do not disable verification.
Show answer
What TTL does the main Resolver receive for fixture.test?
A 60 seconds B The selected UDP port number C No TTL because resolve4 always returns only strings
The ttl option requests address-and-TTL objects, and the controlled response encodes sixty seconds.
Show answer
When the practice feeds two frames as one combined chunk, how many messages are emitted?
A Two: A and é B One containing the entire header and payload bytes C Zero because TCP requires one frame per chunk
The parser loops over complete frames and emits both independently of chunk boundaries.
Show answer
How many items have been processed when the worked checkpoint prints?
A Two B All six because setImmediate is a microtask C Zero because no synchronous batch runs
The first batch runs immediately; the queued checkpoint executes before the next immediate batch.
Show answer
What happens when boundedText receives abcdef with a five-byte limit?
A It cancels and throws Body too large B It returns abcde by silently truncating C It trusts Response construction and ignores the limit
The reader counts six delivered bytes, cancels, and rejects rather than returning a partial document.
Show answer
What decision does the worked confirmation produce for NO?
A false B true because NO is nonempty C AbortError before the answer is consumed
The confirmation accepts only normalized yes; cancellation belongs to the separate second question.
Show answer
Which implementation does createRequire select in the worked dual package?
A main.cjs, printing commonjs B main.mjs because the consumer file is an ES module C Both files concatenated into one export
The require condition selects main.cjs even though createRequire is called from an ES module.
Show answer
What does the bound callback print when invoked inside caller in the worked example?
A source B caller C undefined because binding removes context
bind captured the source scope; the ordinary callback reads caller at invocation time.
Show answer
What results do the two worked tee consumers produce?
A [6,6] B [3,3] because branches alternate items C [6,0] because the first reader consumes every item
tee supplies the sequence to both branches, so each sums 1 + 2 + 3.
Show answer
How many client sessions does the worked /a and /b example create?
A One session containing two request streams B Two sessions because each request must open a socket C Zero because Promise.all replaces the network protocol
Both requests use the same session.request method on one session instance.
Show answer
Which worked inputs pass isQuantity?
A Only the numeric integer 4 B Both 4 and the string "4" because annotations coerce values C All three because unknown disables runtime checks
The real guard requires a number, an integer, and the allowed range; string and fractional values fail.
Show answer
What does the worked directory grant report for a.txt and b.txt?
A true true B true false because only the first file is ever readable C false false because directory grants cannot cover files
The directory grant covers both fixture descendants; the single-file grant covers only a.txt.
Show answer
How many files remain after the worked seven-byte upload exceeds its six-byte limit?
A Zero B One containing abc because partial writes are valid uploads C Two because each chunk becomes a separate file
The failure path removes the owned partial file after pipeline rejects.
Show answer
Why is the worked totalMs 15 rather than 115?
A The listener was removed before the 100-millisecond publication B Negative durations cancel all future positive durations C Every channel automatically keeps only its first two events
Only 10 and 5 were accepted while the listener was registered; unsubscribe prevents the later contribution.
Show answer
No exercises match those filters.