The videos in this section were created using a different editor for p5.js. All of the concepts should still apply, however, there are some minor changes. Most notably in JavaScript let
is now the preferred way to declare a variable over var
. If you would like to learn more about this you can watch this video about let vs var.
- Introduction to Conditional Statements
if
statement- relational operators (
>
,<
,<=
,>=
,==
,===
,!==
)
- Bouncing Ball | Sketch
else
,else if
, AND (&&
), OR (||
)- Boolean Variables
- Chapter 5 of Getting Started with p5.js book | Ebook (free with NYU Library login) | Code
One way to practice working with conditionals is to try to code a common interface elements in the canvas: e.g. rollover, button, slider, etc. In week 7 we'll compare this technique to using elements the browser provides for free.