One can control motors and sensors through a wireless hub using Scratch with Lego Spike. The example below features a mini mini-golf where one can try to make a “hole-in-one”. The motor rotates the arm to hit the ball. There is a color sensor inside the hole. An if-then-else statement presents the result to the user. If the sensor sees the red ball, the “you win” sound with clapping is played, otherwise, the “you lose” sound is played:

The if-then-else statement is of the form if <condition> then <do this> otherwise <do this>. This statement allows our program to do different things based on what happens!