Skip to content

Anonymous Functions

Intermediate · Functions & Errors

A function literal can be defined inline and assigned, passed, or returned. When it references variables from the enclosing scope it becomes a closure — it keeps those variables alive and can mutate them across calls.

Pass an argument to an anonymous function.

Show hint
The function needs a string to print.

Source

Match a closure’s signature and use its argument.

Show hint
You should call the function with a parameter.

Source

Return a closure that remembers state across calls.

Show hint
1 - The `updateStatus()` function should return an order status index like `orderStatus[index]`.
2 - You may need to call `anonymous_func` once more.

Source