The roastery’s order dashboard runs on JavaScript, so the batch planner is moving there too. The port lives in batch-plan/batch-plan.js, next to a package.json holding { "type": "module" }, and runs with node batch-plan.js.
The Python script uses two types, float for kilos and int for batches, and trusts Python to stop when a calculation makes no sense. JavaScript keeps neither promise, and on a quiet Sunday that shows up on the dashboard.
Meet a Single Number Type
In Python, a whole number and a decimal have different types, and true division always gives a float:
>>> type(12), type(17.5)
(<class 'int'>, <class 'float'>)
>>> 3 == 3.0
True
>>> 10 / 2
5.0
Run node with no arguments to start Node.js’s REPL. Ask it the same questions, with typeof standing in for type() and === for ==:
> typeof 12
'number'
> typeof 17.5
'number'
> 3 === 3.0
true
> 10 / 2
5
JavaScript has one type, number, for both. Every number is a 64-bit floating-point value, like a Python float, and a whole number is a float with nothing after the point. Both languages say 3 equals 3.0, but Python compares values of two types, while JavaScript sees one value of one type. Why floats are sometimes inexact, the largest whole number they hold exactly, and BigInt, a separate type for huge integers, are topics for a later course.
So in JavaScript, typeof can’t tell 3 from 3.0, and 10 / 2 never shows 5.0.