...

/

Defining a Function

Defining a Function

Learn the syntax for defining a function.

Structure of a function

A function is defined in the following way:

Press + to interact
returnType functionName (param1Type param1Name, param2Type param2Name) {
function_statement1;
function_statement2;
return returnVar;
}

This seems rather abstract, but we will see a concrete example in a moment. Here’s a breakdown:

  • Return type: On the first line, we have to begin by declaring what data type
...