Page 74 - Dig_CodeAI_V2.1_Class_8
P. 74
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:
72 DigiCode AI (Ver. 2.1)-VIII

