September 2018
Beginner
206 pages
4h 27m
English
The if loop will only run a block of code if a certain condition is TRUE. It can be paired with else statements to create an if/else loop. This will work similarly to an if/else loop in other programming languages, though the syntax may be different.
The usual syntax for using if is as follows:
if(test_condition){some_action}
Here, the action only occurs if the test_condition evaluates to TRUE, so, for example, if you wrote 4 < 5, the code in the curly braces would definitely run.
If there's something you want to happen, even if the test condition isn't true, you would use an if/else, where the syntax usually looks like this:
if(test_expression){some_action}else{some_other_action}
Even if the test_expression isn't true, some_other_action ...
Read now
Unlock full access