Learn Create Your Own Split Screen

Next Page

Ternary operators

Here's another 'pattern' you'll often see in code:
if (score > 50) { outcome= 'passed'; } else { outcome= 'failed'; } alert('you ' + outcome + ' dude !');
Or you might see something like this:
if (health < 20) { ctx.fillStyle = 'red'; } else { ctx.fillStyle = 'green'; }

The general 'pattern' of both examples is "I want something to have one of two values, depending on some condition".