Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Checking multiple cases

What if we want to check more than one cases. Take a look at the sample code above. There we have defined a variable that represents the favorite color of a user (cyan for now), and based on that we want to print to the console a relevant band. 

So if user's favorite color is red, then we give back 'Red Hot Chilli Peppers'.

If is green, we print 'Green Day'

if purple, 'Deep Purple'

Otherwise if none of that we give back 'Black Sabbath'.

Each if (or else if) statements is checked sequentially, the first statement's condition that evaluates to true, executes the following block. Then ALL the following blocks, are ignored