Exit a function and return a value.
One valuable aspect of functions is that they can perform some computations and return the result. The following code has a helper function that returns “hello world” when the function is called. The return value is stored into a variable, which is then printed:
function start() {
var textToPrint = getHello();
println(textToPrint);
}
function getHello() {
var string = "hello world";
return string;
}
Functions can return many different types of results, such as strings, integers, shapes, and more.