Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 89 - 2632_CodeMind
P. 89

    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:

                      88    Premium Edition-VIII

| 84 85 86 87 88 89 90 91 92 93 94 |