This course is about JavaScript’s numbers next to Python’s: dividing, rounding, reading them from text, and formatting them. JavaScript arithmetic rarely stops with an error, so a port that looks right can print the wrong number. Along the way, you’ll port a coffee roastery’s Python batch planner.
The roastery roasts raw, green coffee beans in a drum. Each evening, its planner turns tomorrow’s order into green beans, batches, bags, and cost. Here’s a first taste. The planner counts the full 12 kg batches the drum takes. These are its batch lines in Python:
WEIGHT_LOSS = 0.15
DRUM_KG = 12
order_kg = 37.5
green_kg = order_kg / (1 - WEIGHT_LOSS)
full_batches = int(green_kg // DRUM_KG)
print(f"Batches: {full_batches} full")
Python prints three full batches:
Batches: 3 full
Here are the same lines ported line by line to JavaScript. The batches line keeps its //:
const WEIGHT_LOSS = 0.15;
const DRUM_KG = 12;
const orderKg = 37.5;
const greenKg = orderKg / (1 - WEIGHT_LOSS);
const fullBatches = greenKg // DRUM_KG;
console.log(`Batches: ${fullBatches} full`);
Run it, and the batch count comes out as 44 with 14 decimals:
Batches: 44.11764705882353 full
There’s no error and no warning.
The roastery is two people, selling mostly to cafés, and the roaster pastes in each big order. The order dashboard runs on JavaScript, so you’ll port the planner, one kind of line at a time.
By the end of this course, you’ll be able to:
- Work with one number type, and divide with
Math.floor()and% - Round with
Math.round()andMath.ceil(), without themathmodule - Read numbers from text with
Number(),parseInt()andparseFloat() - Format numbers for people with
.toFixed()andIntl.NumberFormat - Port the whole batch planner to JavaScript
You need to know Python’s arithmetic with int and float (//, %, ** and the math module),
rounding with round(), and format specs such as :.2f. In JavaScript, you need to know how to write
small programs with const, let, if, functions and template literals, and know its types and
===. Any current version of Node.js is fine: the examples use Node 26 and Python 3.15.
The course mixes videos with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course.
Next is a text lesson, Working With One Number Type, which puts Python’s int and float next
to JavaScript’s single number type.