forked from sanijalal/random-dessert-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
25 lines (22 loc) · 749 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
const { getRandomIndex } = require('./helpers/utils')
const { adjectives } = require('./data/adjectives')
const { desserts } = require('./data/desserts')
/**
* Generate a dessert.
* @return {string} A random dessert name
*/
function generateDessert () {
const dessertIndex = getRandomIndex(desserts)
return desserts[dessertIndex]
}
/**
* Generate a dessert with an adjective.
* @return {string} A random dessert name with an adjective
*/
function generateYummyDessert () {
const dessertIndex = getRandomIndex(desserts)
const adjectiveIndex = getRandomIndex(adjectives)
return `${adjectives[adjectiveIndex]} ${desserts[dessertIndex]}`
}
exports.generateDessert = generateDessert
exports.generateYummyDessert = generateYummyDessert