Programs can get long and complicated. Our code may start simple but grow into thousands of lines, often using the same commands over and over. When we write that much code, we make more mistakes and create bugs.
When we find repetitive code, we should consider moving it into functions. Functions are a named group of multiple commands that can make our code shorter and easier to read. Once we’ve defined a function, we can use one line to repeat that block of code.
Let’s get started with functions.
Move Left and other commands are functions themselves. Each time we place the command, it handles all of the logic behind the scenes to move Codey around.
To solve this exercise, move Codey to the goal.
Move Right Move Right Move Right Move Down