Thanks for the advice GiGs. Finally, I've noticed you like to use switch Vince. There are
places it's good to use it, but if you are just returning a single value
an array or object is better. It's usually a lot less code and may be
easier to read. I suppose I thought switch was perfect when checking against a single test with "potentially" lots of outcomes. (only 3 in my example but a large table could be much bigger). The array seems like a great option and sadly, I would have never thought of that with my troglodyte js brain. ;-P Here's an updated version that uses an array of outcomes. Definitely alleviates some of my superfluous code and logic. <button type="action" name="act_random-roll">Roll</button> <script type="text/worker"> on('clicked:random-roll', (eventInfo) => { // an array of outcomes const outcomes = [ '&{template:default}{{name=Random Result}}{{One}}', '&{template:default}{{name=Random Result}}{{Two}}', '&{template:default}{{name=Random Result}}{{Three}}', ]; // randomly determine an outcome against the array const randomNumber = Math.floor(Math.random() * outcomes.length); const roll_string = outcomes[randomNumber]; // post the outcome startRoll(roll_string, (roll) => { finishRoll(roll.rollId); }); }); </script>