# Manually defined functions don't work when running experiment online

**URL:** https://discourse.psychopy.org/t/manually-defined-functions-dont-work-when-running-experiment-online/14447
**Category:** Online experiments
**Created:** [June 22, 2020, 8:13am UTC](https://discourse.psychopy.org/t/manually-defined-functions-dont-work-when-running-experiment-online/14447 "2020-06-22T08:13:14Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![niclai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/niclai/32/4405_2.png) [@niclai](https://discourse.psychopy.org/u/niclai)
#### Post date: [June 22, 2020, 8:18am UTC](https://discourse.psychopy.org/t/manually-defined-functions-dont-work-when-running-experiment-online/14447/2 "2020-06-22T08:18:44Z")

</div>

I think you need to double define your functions because they are not inmediately assigned to the name you geve them in JS. Have a look at this:

> [@Custom function not defined when called from a different routine](https://discourse.psychopy.org/t/custom-function-not-defined-when-called-from-a-different-routine/13519):
>
> When running the experiment from the builder in Pavlovia I get the following problem. I define the following custom function using a code snippet at the beginning of the experiment. It just chooses a random number that I use later. doJitterLine is also defined at the beginning of the experiment. function jitterLine(doJitterLine) { if (doJitterLine) { return [3,4,5,6,7][Math.floor(Math.random() \* 5)] \* (Math.round(Math.random()) \* 2 - 1); } else { return 0; } Howeve…

---

_[View the full topic](https://discourse.psychopy.org/t/manually-defined-functions-dont-work-when-running-experiment-online/14447)._
