diff options
Diffstat (limited to 'src/util/sugar.js')
-rw-r--r-- | src/util/sugar.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js index 3fa3fb46..3c5c2e9a 100644 --- a/src/util/sugar.js +++ b/src/util/sugar.js @@ -60,6 +60,11 @@ export function repeat(times, array) { return out; } +// Gets a random item from an array. +export function pick(array) { + return array[Math.floor(Math.random() * array.length)]; +} + // Gets the item at an index relative to another index. export function atOffset(array, index, offset, { wrap = false, |