# Functions

## Create a function

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn66y6xaGnS4Hk6xQY%2Fblocks-function-%E2%9C%95-fig-1.png?generation=1524497178346736\&alt=media)

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

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn66yofZprsTAIvpdb%2Fblocks-function-%E2%9C%95-fig-5.png?generation=1524497158447313\&alt=media)

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

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXkwTIGdwg-GzyOxTd5%2F-MXkxZznumk5UpU8CZI6%2FScreen%20Shot%202021-04-08%20at%2011.10.29%20AM.png?alt=media\&token=25dc3467-8a09-4c42-8216-4ff02e49c7c4)

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

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXkwTIGdwg-GzyOxTd5%2F-MXkxr4I8faPM_UhjOWX%2FScreen%20Shot%202021-04-08%20at%2011.11.45%20AM.png?alt=media\&token=ff42353b-8d25-4249-8b57-5df1267ccc24)

## Create a function with an output

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

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MBmyLkaLb0XFn8rjwoA%2F-MBnDFgRiSp4Hg9osvFn%2Fdoandreturn.png?alt=media\&token=38280a10-4084-4f09-a6db-5d7bd3b958ea)

### 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:

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MBmyLkaLb0XFn8rjwoA%2F-MBnEGfugDVrF6z8coeU%2Fqualfunc.png?alt=media\&token=482b86ca-78c9-4a64-b25e-c9c619e7d6f1)

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>" %}
