Menu

Functions let you name a block of code and reuse it. bubblecode has two kinds: functions (which give back a value) and handlers (which perform an action).

Functions (return a value)

A function calculates something and gives you the result:

fn.bubble

Handlers (perform an action)

Handlers use on instead of function and don’t return a value — they just do something:

handler.bubble

Multiple parameters

Functions and handlers can take multiple parameters separated by commas:

multi.bubble

Using functions inside expressions

Since functions return values, you can use them anywhere you’d use a number or string:

compose.bubble

Exercise

Exercise

Write a function called "triple" that takes a number and returns it multiplied by 3. Then print the result of triple(7).

exercise.bubble

Quiz

Question 1 of 3

What is the difference between a function and a handler?