From ea20382f623c78d980af1f06a22ab22e141c19d8 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sun, 9 Jan 2022 01:42:00 +0900 Subject: [PATCH] Create random.js --- lib/random.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/random.js diff --git a/lib/random.js b/lib/random.js new file mode 100644 index 0000000..508b3af --- /dev/null +++ b/lib/random.js @@ -0,0 +1,16 @@ +function getInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} + +function one(arr) { + return arr[range(0, arr.length - 1)]; +} + +exports.getInt = getInt; +exports.one = one; + +exports.VERSIONINFO = "Random Module (random.js) version 0.1"; +exports.global = global; +exports.require = global.require;