-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (30 loc) · 880 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
const fs = require('fs')
const tourData = require('./tour.json')
const restaurantData = require('./restaurants.json')
const mallData = require('./malls.json')
const babyGirlsData = require('./babygirls.json')
const babyBoysData = require('./babyboys.json')
function getRandomSuggestions(type) {
let length, index, data
length = 500
index = Math.floor(Math.random() * length)
if (type === 'tour') {
data = tourData[index]
return data
} else if (type === 'restaurants') {
data = restaurantData[index]
return data
} else if (type === 'malls') {
data = mallData[index]
return data
} else if (type === 'babygirls') {
data = babyGirlsData[index]
return data
} else if (type === 'babyboys') {
data = babyBoysData[index]
return data
} else {
return 'Please set a valid parameter'
}
}
module.exports = getRandomSuggestions