30 Days Of JavaScript

Day 3: Logic

Wrap up

Congratulations on finishing another day 😀

Conditional logic and this kind of flow control is a big part of programming and, while it might seem confusing right now, in time it will become second nature.

This is the first time we have taken an earlier concept, booleans (true/false), and combined it with something new so if you're brain is spinning that's to be expected.

Exercise

To wrap up today I have a small task for you to complete. In the playground below we have 2 weather inputs, temperature and conditions.

temperature can be any number and conditions can be any of: raining, sunny and foggy.

Based on the conditions and temperature we need a script that will console.log() a message for what to wear. Let's keep it to 6 outputs so it's not too much code, the clothing advice will be:

ConditionsBelow 15°CAbove 15°C
RainingThick CoatThin Coat
SunnyLight JumperT-Shirt
FoggyBright CoatWhere Are You?

Once you've got that working, then add an override variable called bothered, if bothered === true then run through the above code and console.log() the result. If the user is not bothered (=== false) then skip the whole section and console.log() "Best of luck!"

(Remember you can make the coding playground area wider by hovering on and dragging the vertical divider)

Time for a quiz

It good to test your knowledge just after learning something new, it solidifies the connections in your mind and identifies any areas that you should go back over.

The Pro version of 30 Days of JavaScript comes with a 10 question multiple choice quiz at the end of each day, if you want to take these quizzes (and get a host of other Pro features) then consider:

Joining Pro today

Outline

Go Pro?

If you upgraded to pro, sign in here

  • About
  • Blog
  • Privacy
Looking to email me? You can get me on my first name at allthecode.co