Conditionals are very common in all languages of programming. A conditional is a piece of code that, when a certain condition is met, performs an action. An example of this is an “if do” block:
If the condition next to the “if” part of the block is true, the code will run the actions next to the “do” part of the block. For example, if you run this code:
When the button is clicked, the code checks if 0=0. If this is true, then the code will navigate to the Welcome Screen. Since 0 always equals 0, this code will always navigate to the Welcome Screen.
An “if else” statement works the same way, but if the condition in the “if” part of the block is not true, the code will run the actions that are under the “else” part. An example in real life would be checking the weather. You can think of your choices like an “if else” statement; if it is sunny, go to the beach, or else, watch a movie. Here is an example in coding:
When the button is pressed, the code checks if 2=0. Since 2 doesn’t equal 0, the code under the “else” part of the block runs, so the label changes to say “2 is not equal to 0”