« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/sugar.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/sugar.js')
-rw-r--r--src/util/sugar.js5
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,