Sikau

JavaScript · Day 17 · about 30 min

Project: Weather advisor

Advice from temperature and rain chance.

Your first project

Time to put Unit 3 together! You'll build a small weather advisor that looks at the temperature and the chance of rain and tells you what to wear.

  • Decide on clothes from the temperature (else if).
  • Add rain advice (logical operators).
  • Put it into one friendly sentence (template literal + ternary).

Plan before you code

Programmers sketch the rules in plain words first. Here are ours:

  • Below 10°C → coat
  • 10 to 19°C → jumper
  • 20°C or more → t-shirt
  • Rain chance 50% or more → also take an umbrella

Writing rules as a list first makes the code almost write itself. Each bullet becomes a condition.

The rest of this lesson

  • Turning rules into codeexplain
  • Check the advicepredict
  • Rule to codematch
  • Step 1: clotheswrite code
  • Step 2: the full advicechallenge
  • Badge quizquiz
  • Unit 3 complete!recap

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript