Functions are ideal when you need to perform an action multiple times. Instead of repeating a block of code in your script, you can put the code in a function and simply [call the function](/js/call) when needed.
*Why use functions?* Functions makes your code easier to read, debug, and update.
### Add a function
To add a function to a Touch Develop script:
1. Open a script and then click `script` (in the upper-right corner).
2. Click `+`**add new**.
3. Click **function()**.
A new function appears, like this:
```
export function doStuff(p: number) {
}
```
Functions begin with the `function` keyword and end with `end function`. The function name appears after the `function` keyword (in this case, `do stuff`).
### ~hint
Click the function name to edit the function properties (i.e. change the name or add parameters - see below).
Click the parameter name to rename it and click the [type](/js/types) to change the variable type. For more info, see [function parameters](/js/functionparameters).
Use a [comment](/js/comment) at the beginning of your functions to describe the function. When you insert a function into your code, the comment text appears in the help area of the Code Keyboard.
To see all the functions in a script, open the script and then click `script` (in the upper-right corner). All of the functions in your script appear under **code**.
### ~hide
### Private functions
If you don't want people to see the code in your function, you can make the function private. To do this, open the function, click the function name, and then mark the **private function** check box. Private functions have a locked icon instead of a play icon.