Conditionals | MDN

If, else if, Else

This block is used when some condition is met. If the first condition is not met, check the second condition. If the second condition is not met, then move on. If no conditions are met, then do the code in the else block.

if (condition){somecode;} -> does this code

if else(condition){somecode;} -> if the condition is met, do this code

else{} -> does some other thing.

In short, if the first statement is not true, then the second condition is checked (we can use an else if). We can use this to control the flow of our code.

Comparators

These are used to check the condition of some variable a against some variable b (ex. a > b, a === b, a <= b).

It is also possible to combine these comparators

Leap Year Coding Challenge

View Page Here

It is recommended that anyone working through something with many conditions to use a flowchart to help with the logic behind the problems.