This course is about how JavaScript makes decisions: else if chains, combined conditions, the
conditional operator, and switch. Your project is to port the Python script a sailing club
member wrote to post Saturday’s race-day call.
Here’s a first taste, on a blustery morning with 25 knots of wind, gusting 28. The club races from 6 knots up to, but not including, 25. This Python code checks the club’s wind range:
wind_knots = 25
if 6 <= wind_knots < 25:
print("racing (good racing wind)")
elif wind_knots < 6:
print("postponed (too little wind)")
else:
print("postponed (too much wind)")
Python posts the right call:
postponed (too much wind)
Here’s the JavaScript port, line for line:
const windKnots = 25;
if (6 <= windKnots < 25) {
console.log("racing (good racing wind)");
} else if (windKnots < 6) {
console.log("postponed (too little wind)");
} else {
console.log("postponed (too much wind)");
}
It runs with no error and posts this:
racing (good racing wind)
Look at the 25: that’s too much wind for the club, but the port says racing. A line-for-line
port can quietly give a different answer, and this course shows you where, and what JavaScript
does instead.
A small sailing club races dinghies every Saturday. Ruth, one of its members, wrote a short Python script that reads the club’s weather station and the coastal forecast and posts the call: racing, postponed, or canceled, with the reason. The club’s website is moving to a JavaScript back end, so you’ll port the script, one decision at a time.
By the end of this course, you’ll be able to:
- Write an
else ifchain with each branch in braces, and declare the variables it sets above it - Pick one of two values with the conditional operator, condition first, and drop it into a template literal
- Combine conditions with
&&,||, and!, and negate a whole comparison - Check that a reading falls in a range
- Ask about one of several values with
.includes(), and about emptiness with.length - Match one value with
switch,break, stacked cases, anddefault, or look it up in an object - Put Ruth’s whole race-day call together in JavaScript
You only need to know Python’s conditionals as you use them every day: if, elif, and else,
and, or, and not, chained comparisons, conditional expressions, and match over one value.
In JavaScript, you only need to know how to write a small program with const, let, if and
else, template literals, arrays, and objects.
A current version of Node and of Python is fine: the examples use Node 26 and Python 3.15.
The course mixes short videos and text lessons, with exercises where you write the code yourself. Every video has notes below it. A project puts Ruth’s whole script together, and a quiz and a summary close the course.
Next up: Making the Call With else if and the Ternary, where Ruth’s first draft of the call
goes from an elif chain to JavaScript’s else if.