From 68aaafc3d7139de9207684586d3e2be63f00a78f Mon Sep 17 00:00:00 2001 From: zahadneokurkycz <78108685+zahadneokurkycz@users.noreply.github.com> Date: Sat, 18 May 2024 15:45:51 +0200 Subject: [PATCH] Update index.js --- lib/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index aeee2bab8..a6a745d96 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,10 +2,10 @@ * * @author Vinit Shahdeo */ -const arr = require('../data/data.json'), +import arr from './data.json' assert {type: 'json'} // utility to generate a random number - randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1) + min), + let randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1) + min), index = randomInt(0, arr.length), // random index to be used /** @@ -23,6 +23,8 @@ const arr = require('../data/data.json'), * To hide author, pass options as { author: false } */ getQuote = (options) => { + randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1) + min), + index = randomInt(0, arr.length), // random index to be used !options && (options = {author: true}); // default option return { text: arr[index].text, @@ -30,7 +32,7 @@ const arr = require('../data/data.json'), }; }; -module.exports = { +export { getRandomQuote, getQuote };