It starts with a bill that says $NaN
The most important story in this course. Some version of it happens every day in JavaScript projects.
Day three after the tea shop app went live
You wrote an ordering app for a bubble tea shop. Menu, cart, checkout, all in JavaScript. The tests passed and it went live. One line calculates the two-cup discount: const bill = order.totle * 2. You have probably already spotted it: total is spelled totle.
JavaScript did not spot it. Reading a property that does not exist is not an error in JavaScript. It quietly returns undefined. undefined times 2 is not an error either. It returns NaN. Putting NaN into a string is still not an error. So at 1:47 a.m., a customer buying two cups saw "Total: $NaN", took a screenshot, and sent it to support. You got up at 3 a.m. and read log lines for two hours before you found five letters.
The same code in a .ts file behaves differently. The moment you save the file, the editor underlines it: there is no totle here, did you mean total? It even suggests the fix.
Reading a missing property is legal JavaScript. You get undefined and no warning, so the place where the bug is born produces no signal at all.
undefined in an arithmetic expression becomes NaN, and NaN is passed on to whatever comes next. The bad value travels far from where it started.
By the time you see the problem, you are far away from the line that caused it. You have to trace backwards from the symptom.