WITH FUSS OR QUIBBLE...

In principle, the JavaScript programming language is represented visually by the blocks. This allows you to use queries and dependencies that you might already know. For example, you can check if a certain condition is fulfilled. Such a dependency is the "if" block in the following example.

Here, similar to loops, the "if" condition is checked first. If it is true, the corresponding statement block is executed once. Afterwards, the program continues directly with the rest of the program. If the condition does not apply, the statement block is simply skipped.

TIP: During loops, "block" the rest of the execution until the condition is no longer met, the rest of the program can still be executed if "if" conditions are met.

In the following example we will check the left obstacle sensor again and switch on the light when the sensor detects an obstacle.

"If" conditions can be optionally extended by an "Otherwise" block. Either the program statement from the first block is executed, if the condition is true, or an alternative block is executed. This principle can be thought of as a road branching off to the left or right. Depending on whether the condition is true, it is decided which way to go.

Of course, it can also be checked for several different conditions in a row in one program. In the next step we first check the left obstacle sensor to switch on the headlights and then the right obstacle sensor to switch on the reversing light.

In this case we use a total of two "if" conditions. This means that both conditions can apply at the same time, so both the headlights and the reversing light can be on at the same time.

But this is not always what is wanted. Sometimes an "either-or" is simply not enough. For this case the "if" condition can be extended by any number of additional blocks. Several "if" queries are set one after the other. The big difference is, that no matter how many queries are set in a row, only one single condition can be true. As soon as a condition is fulfilled, the corresponding statement block is executed and all other conditions are skipped.

In the following example we will check the two obstacle sensors again. But here the query is realized by a contiguous "if" condition and not by two single ones. This means that only either the headlights or the reversing light can be lit, but never both at the same time.

-