Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
In a layered configuration system (defaults → config file → environment variables), which layer should take final precedence when values conflict?
💻 Code Challenge | +75 XP
Build a layered config module that merges a defaults object, a per-NODE_ENV JSON file, and process.env overrides (in that precedence order), then freezes the final result.
A config object was accidentally mutated deep inside a request handler, causing intermittent bugs that only appear after the first request. Reorder the steps to fix and prevent recurrence.
Task: Reorder the blocks in logical sequence to solve the problem.
A.D.A. Interface
Adaptive Didactic Assistant

Pascual Vila
Frontend Instructor // Code Syllabus
The Error //
Mutating a shared configuration object somewhere deep in application logic
// Wrong: a stray mutation silently breaks the rest of the app
config.port = getDynamicPort();
// Correct: frozen config throws on mutation attempts (strict mode)
export const config = Object.freeze({ port: 3000 });The Solution //
A config object is typically imported and shared across many modules; mutating it in one place silently changes behavior everywhere else that imports it, often intermittently depending on request order. Freeze the resolved config object with Object.freeze() immediately after building it, so any accidental mutation throws instead of silently corrupting shared state.
The Error //
Logging the entire resolved configuration object at startup without excluding secrets
// Wrong: logs the DB password straight into your log aggregator
console.log("Starting with config:", config);
// Correct: log only what's safe
console.log("Starting with config:", { port: config.port, env: config.env });The Solution //
A convenient "log config at boot for debugging" habit becomes a security incident the moment that config object contains a database password or API key, since logs are often shipped to less-secured aggregation systems than the secrets themselves. Explicitly log only the non-sensitive subset of configuration, never the whole object.