Beginner Coding with Blocks
Chapter
>
Level
Advanced Functions and Patterns
Functions with Multiple Parameters
Objective
Grab the materials in the field so you can build the chickens some new houses.
The chickens need some new coups, you can build various types of chicken houses using functions with multiple parameters. Functions can take multiple parameters, allowing you to pass different values for each property.
Use the define function to return block to create a function named get_chicken_house. Add two parameters: color and size. Inside the function, use a text join block to combine "chicken_house|", the color parameter, "|", and the size parameter. This creates a build string like "chicken_house|blue|small".
Functions with multiple parameters allow you to pass different values for each property when you call the function. For example, calling get_chicken_house with "blue" and "small" will return "chicken_house|blue|small", and calling it with "green" and "big" will return "chicken_house|green|big".
Collect all planks in the field and walk to the X marks. Use the build block with the call function block, passing the appropriate color and size arguments to create all 4 different houses: small blue, big green, small red, and big orange.