Your port can now tell whether the wind sits in the club’s range. Ruth’s script asks two questions before it looks at the wind, though. Is a warning in force, and is the forecast thunder or fog? Either one cancels the race, however good the breeze.
Both checks lean on Python shortcuts. Ported line by line, each one runs without an error and answers a different question from the one Ruth meant, so nothing tells you the call is wrong. In this lesson, you’ll ask JavaScript the question you mean. Start with the forecast.
Ask Whether the Forecast Is Thunder or Fog
On the fog morning, the forecast word is "fog", and the race has to be canceled. Ruth’s script checks for both bad forecasts at once with in on a tuple:
forecast = "fog"
if forecast in ("thunder", "fog"):
print(f"cancelled ({forecast} forecast)")
It prints cancelled (fog forecast). JavaScript has no tuples, so the fixed group becomes an array literal. To ask whether an array holds a value, you call its .includes() method, which compares values without type conversion and returns true when it finds a match:
const forecast = "fog";
const badForecast = ["thunder", "fog"].includes(forecast);
console.log(badForecast);