Page 67 - Computer_Genius_v2.1_C7_flipbook
P. 67

4.  Call the Function:
                    o  To use the function, you need to “call” it. Drag and drop a “call movePlayer” block (or whatever
                      you named your function) where you want the function’s code to be executed.

                 Function Arguments and Parameters

                 A function is a block of code designed to perform a specific task. It can take inputs, process them,
                 and return an output. Functions help to organize code, make it reusable, and improve readability. A
                 function may accept different values in the form of:
                   Parameter: A variable defined in a function’s definition. It’s like a placeholder for a value that
                   will be passed to the function when it’s called.

                   Argument: The actual value passed to a function when it’s called. It fills in the placeholders
                   defined by the parameters.
                 Let us create a project that demonstrates the use of function block for calculating area of a rectangle
                 using parameters and arguments. Prepare the project in MakeCode Arcade as shown below:


























































                                                                                Advanced MakeCode Arcade      65
   62   63   64   65   66   67   68   69   70   71   72