Skip to Content
0 likes
Custom Error Classes You Can Actually Catch Level: Intermediate

Stop checking error messages with includes(). Extend Error, set name, add the fields the handler needs, catch with instanceof, and wrap low-level errors with cause so the real reason isn't lost.

0 likes
Why Your Date Is Off by One Day Level: Intermediate

Your date moves a day because one part of the code uses UTC and another uses local time. Find which step does it, keep calendar days as YYYY-MM-DD strings, and name the time zone when you format.

0 likes
Destructuring Function Parameters With Defaults Level: Intermediate

Replace long lists of positional arguments with one options object, destructured in the parameter list with defaults. Add = {} so a call with no argument doesn't crash, and know that defaults only replace undefined.

0 likes
Fix "Cannot use import statement outside a module" Level: Intermediate

The file was loaded as a classic script or CommonJS, where import isn't allowed. The fix in the browser is type="module". In Node it's "type": "module" or .mjs, and recent npm init writes "type": "commonjs" for you.

0 likes
fetch With Proper Error Handling (It Doesn't Throw on 404) Level: Intermediate

fetch only rejects when there's no response. A 404 or 500 resolves normally, so check response.ok, add a timeout, and keep the status on the error so the caller can decide what to tell the user.

0 likes
Install Node.js and Check It Actually Works Level: Intermediate

Install the LTS version of Node.js, check the installer's signature, and prove it works in a new terminal with node -v, npm -v and one real install. Plus the fixes for "not recognized" and the wrong version showing.

0 likes
Fix "Unexpected token in JSON" Errors Level: Intermediate

"Unexpected token in JSON" means JSON.parse got text that isn't JSON. Read the exact message, log the raw text, and match it to one of five causes. Most of the time it's an HTML error or login page.

0 likes
map, filter, reduce on a Real List of Orders Level: Intermediate

Five questions a manager would ask about a list of orders, each answered with map, filter, reduce or a plain loop. Real data includes an empty order, and the code has to survive it.

0 likes
npm install vs npm ci: Same Install on Every Machine Level: Intermediate

Use npm ci to install exactly what the lock file says and npm install to change it. What each command does, when to use which, and how to fix "npm ci can only install packages when your package.json and package-lock.json are in sync".

0 likes
Your First Test With Vitest Level: Intermediate

Add Vitest to a project you already have and get real tests passing: a pure function with it.each, then an async function that calls fetch, tested with a fake instead of the network.

0 likes
Card Component You Can Drop on Three Pages Level: Intermediate

Reuse one card across home, catalog and related-item contexts, test long content and keep each action accessible without nested links.

0 likes
Fix Horizontal Scroll on Mobile in 10 Minutes Level: Intermediate

Reproduce a fixed-width overflow on a narrow screen, locate the offending element and verify a repair without clipping the page.