Else If

Alright, let’s get a bit more sophisticated. I want to print out a bunch of different messages depending on the temperature:

  • If it’s 10 or under, we say “it’s cold”

  • If it’s between 11 and 25, we say “it’s nice”

  • If it’s between 26 and 30, we say “it’s warm”

  • If it’s over 30, we say “it’s hot”

We could do this with just our if and else approach, by nesting ifs inside our elses. If you want a challenge exercise, try to do that yourself now. Here’s my solution:

Get hands-on with 1200+ tech skills courses.