-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathindex.js
35 lines (31 loc) · 926 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
let array = require("./data/data.json");
let inspireArray = require("./data/inspire.json");
let favline = {};
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
module.exports.getRandomLine = function (type) {
let index = randomInt(0, array.length);
switch (type) {
case "isp":
index = randomInt(0, inspireArray.length);
return inspireArray[index].quote;
default:
return array[index].line;
}
};
module.exports.getLines = function (type) {
let index = randomInt(0, array.length);
switch (type) {
case "isp":
index = randomInt(0, inspireArray.length);
favline.quote = inspireArray[index].quote;
favline.author = inspireArray[index].author;
return favline;
default:
favline.line = array[index].line;
favline.book = array[index].book;
favline.author = array[index].author;
return favline;
}
};