Repeat an action
Use repeat to run code an exact number of times instead of writing it out manually.
whenGreenFlag(() => { repeat(5, () => { changeX(20); wait(0.1); });});This moves the sprite 20 steps to the right, five times in a row, with a short pause between each step β producing a stepping effect across the stage.
Functions used
Section titled βFunctions usedβwhenGreenFlagβ run code when the green flag is clickedrepeatβ run a block of code a fixed number of timeschangeXβ move along the x axiswaitβ pause the script for a number of seconds