Loading…
Loading…
New file in the project — a colleague is creating a utility for filtering products and checking stock. It passes the tests, but it already crashed in prod on "weird" products. Walk the diff and find every loose-equality and truthy/falsy trap.
JavaScript has two huge bug categories: 1. **Loose equality (`==`, `!=`)** — comparison with type coercion. `'0' == 0 == false` is `true`. Hell. 2. **Truthy/falsy coercion** — when you write `if (x)`, JS turns `x` into a boolean by non-obvious rules. `0`, `''`, `null`, `undefined`, `NaN`, `false` — all falsy, everything else truthy. Rule: always `===`, always explicit checks. Walk the code and find every trap.