conditional

This commit is contained in:
gauthiier 2023-01-09 13:21:42 +01:00
parent ce935cfc33
commit 8aaa3b599f

View File

@ -155,3 +155,37 @@ function draw() {
// Reference: https://p5js.org/reference/ // Reference: https://p5js.org/reference/
``` ```
## 🤔 What are conditional statements (i.e. if-statements)?
```javascript
if(conditionX) {
// if conditionX is true then
// execute this piece of code {} block
// then exit the if/else statement
} else if(conditionY) {
// if conditionX is false then
// if conditionY is true then
// execute this piece of code {} block
// then exit the if/else statement
} else if(conditionZ) {
// if conditionX and conditionY are false then
// if conditionZ is true then
// execute this piece of code {} block
// then exit the if/else statement
} else {
// if all of the above conditions are false then
// execute this piece of code {} block
// then exit the if/else statement
}
```
Ok ok, but what are "conditions" then?
<p align="center">
<img src="https://git.le-club-des-sans-sujets.org/gauthiier/Revisiting-Concepts-Notations-Software-Art/media/branch/main/img/comparing-operators.png" height="450"/>
</p>