# Functions

## Create a function

![](/files/-LAn66y6xaGnS4Hk6xQY)

To create a function, you will need to specify if it has any inputs and give it a name

![](/files/-LAn66yofZprsTAIvpdb)

One example of a function is below. This function will create and shuffle a list of items.

![](/files/-MXkxZznumk5UpU8CZI6)

After you have created your function, you can simply use it at any time using the function block you have named

![](/files/-MXkxr4I8faPM_UhjOWX)

## Create a function with an output

You can also create a function that returns a specific output.

![](/files/-MBnDFgRiSp4Hg9osvFn)

### Conditional Outputs

You can add multiple `return` blocks to your function. This allows you to return a different output based on some conditions.

For example, this function will take a rating out of 100, and return a description of the quality of the item being reviewed:

![](/files/-MBnEGfugDVrF6z8coeU)

The function will break when the `return` block is fired. For example, in the above example, if the quality rating is 100, the function will return **Perfect** and then stop. It will not run the other tests, and won't return **Excellent**. **Good**, **Fine**, etc.

{% embed url="<https://youtu.be/NgDamxAfC5Y>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thunkable.com/snap-to-place/functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
