🤔 IF Statements | Betabox

🤔 IF Statements

IF statements are other powerful tools in the programmer’s toolbox. To find them in Scratch, you will need to look in the Control folder.

IF statements are used for logic. First, the statements check IF something is true or false and then run code based on the result.

Let’s make a quick example of a program that will move 2 steps forward and 1 step back.

Try this program out for yourself!

The loop works by first checking to see if our variable Steps is < 2. If the variable is less than 2 then it will move forward and add 1 to Steps. If it isn’t less than 2 then it will execute the code in the else area. This code will move the car backwards and set the number of steps back to 0.