aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.ts
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-03-16 22:34:43 +0100
committerMaksymilian Jopek <maks@jopek.eu>2022-03-16 22:34:43 +0100
commitf8c006414aec99c90558587dbe08cf1705ed44f7 (patch)
tree2f52ea7f071f91e5e53e4dfdde9cdd2b8d7cd4dc /src/utils.ts
downloadboules-f8c006414aec99c90558587dbe08cf1705ed44f7.tar.gz
boules-f8c006414aec99c90558587dbe08cf1705ed44f7.tar.zst
boules-f8c006414aec99c90558587dbe08cf1705ed44f7.zip
Initial commit w/ v0.0.1
Diffstat (limited to 'src/utils.ts')
-rw-r--r--src/utils.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils.ts b/src/utils.ts
new file mode 100644
index 0000000..0dc0bb1
--- /dev/null
+++ b/src/utils.ts
@@ -0,0 +1,9 @@
+/**
+ * Returns a random number between min (inclusive) and max (exclusive)
+ */
+export function getRandomInt(min: number, max: number): number {
+ return Math.floor(Math.random() * (max - min) + min);
+}
+export function getRandomEl<T>(arr: Array<T>): T {
+ return arr[getRandomInt(0, arr.length)];
+}