From 73646482c98767968454496de506b1012b87188f Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Fri, 21 Oct 2022 22:52:07 +0200 Subject: [PATCH] Added random pick module. --- src/utils/pick-random.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/utils/pick-random.js diff --git a/src/utils/pick-random.js b/src/utils/pick-random.js new file mode 100644 index 0000000..779af95 --- /dev/null +++ b/src/utils/pick-random.js @@ -0,0 +1,9 @@ +'use strict'; + +const crypto = require('crypto'); + +function pickRandom(array) { + return array[crypto.randomInt(0, array.length)]; +} + +module.exports = pickRandom;