Level 1 exam — harder

Exam — fresh questions

1.1 · Recall

1. Which reflex to adopt for declaring variables in modern JavaScript?

const by default (stable reference, block scope), let if the value changes, var banned.
1.1 · Application

2. Salim wants the names of active users from a users array. Modern writing?

filter keeps (the active ones), map transforms (their names): the intention reads at a glance.
1.1 · Arbitration

3. Salim re-reads const config = { port: 3000 } then config.port = 4000. Your call?

const protects the “box” (the reference), not its content: changing a field stays possible.
1.2 · Recall

4. What does await do in an async function?

await suspends the function while waiting for the Promise without blocking the event loop.
1.2 · Application

5. Salim's console.log shows undefined just after an asynchronous call. Cause?

Launching is not getting: the result arrives later (callback, .then() or await).
1.2 · Application

6. Salim chains three dependent operations (file → database → API). Recommended writing?

async/await: code reads in order, without blocking, errors handled in the same place.
1.3 · Application

7. Salim imports his local calculs.js module with CommonJS. Correct syntax?

Local module = path with ./ or ../; bare name = native (fs) or npm package.
1.3 · Application

8. Salim starts a new project and wants the standard syntax (same as front-end). Choice?

ESM = language standard, consistent front/back, recommended for a new project.
1.3 · Arbitration

9. Salim's project mixes require and import in the same file and crashes. Your call?

One system per file: the config decides, don't mix without explaining it.
1.4 · Recall

10. What should be versioned in Git for a Node project?

The recipe (json + lock) is versioned; node_modules regenerates via npm install.
1.4 · Application

11. Salim installs a restart tool only useful in development. Command?

-D marks dev packages: needed on the machine, not in production.
1.4 · Arbitration

12. Before releasing, npm audit reports a vulnerability in a dependency. Your call?

Dependencies are a real attack vector: audit → update → test → release.
What's next?
Back to the guideGuide contents