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

Example Flow Variables - Using variables and a custom function

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

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:

  • 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.
1 Like