# H.O.O.P. (Hope) - Examples

**URL:** <https://community.homey.app/t/h-o-o-p-hope-examples/45114>\
**Category:** Tutorials\
**Tags:** app, tools, tutorial, flow\
**Created:** [March 23, 2021, 6:05am UTC](https://community.homey.app/t/h-o-o-p-hope-examples/45114 "2021-03-23T06:05:48Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 23, 2021, 7:27am UTC](https://community.homey.app/t/h-o-o-p-hope-examples/45114/4 "2021-03-23T07:27:46Z")

</div>

### Example Flow Variables - Using variables and a custom function

First i created a function called “random” in the App Settings:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/d/cda56a704a1a05944c04331832396ea2b09d2a1f.png)

**Enter the next javascript into the function by clicking edit.**

```
function (arr) {
  return arr[Math.floor(Math.random() * Math.floor(arr.length))];
}

```

Then the next flow:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/7/b7f26d046ab6d49db98933fbc4b8ee669d09ea11.png)

- First, put a Javascript Array into a Flow Variable type JSON called Kids.  
(Variables are created on the fly, no need to define them in settings, just start the flow to use them)
- Then set Flow Variable Testname (type String) to: random(Flow Variable - Kids).  
(The returning type needs to be the defined type, in this case a string. JSON accepts any kinds of input)
- Now you can use the Flow Variable - Testname and send it to your watch, or use it the way you need it.

---

_[View the full topic](https://community.homey.app/t/h-o-o-p-hope-examples/45114)._
