forked from sanijalal/random-dessert-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into run-test-on-every-git…
…-push
- Loading branch information
Showing
9 changed files
with
69 additions
and
1,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
exports.adjectives = [ | ||
'bbq', | ||
'berrylicious', | ||
'butterscotch', | ||
'caramel', | ||
'cheesy', | ||
'chocolate', | ||
'salted egg', | ||
'salty', | ||
'smoked', | ||
'strawberry', | ||
'sugar', | ||
'sweet' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
exports.desserts = [ | ||
'ais kacang', | ||
'akok', | ||
'apple crumble', | ||
'brownies', | ||
'buchty', | ||
'cake', | ||
'cekodok', | ||
'cempedak creme', | ||
'cempedak fritters', | ||
'cendol', | ||
'chocolate', | ||
'cupcake', | ||
'eclair', | ||
'frgál', | ||
'kek lapis', | ||
'krapfen', | ||
'kremrole', | ||
'muffin', | ||
'tart', | ||
'větrník' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function getRandomIndex(array) { | ||
return Math.floor(Math.random() * array.length); | ||
function getRandomIndex (array) { | ||
return Math.floor(Math.random() * array.length) | ||
} | ||
|
||
exports.getRandomIndex = getRandomIndex; | ||
exports.getRandomIndex = getRandomIndex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
const utils = require('./helpers/utils'); | ||
|
||
const desserts = ['ais kacang', 'akok', 'apple crumble', 'brownies', 'buchty', 'cake', 'cekodok', 'cempedak creme', 'cempedak fritters', 'cendol', 'chocolate', 'cupcake', 'eclair', 'frgál', 'kek lapis', 'krapfen', 'kremrole', 'muffin', 'tart', 'větrník'] | ||
const adjectives = ['bbq', 'berrylicious', 'butterscotch', 'caramel', 'cheesy', 'chocolate', 'salted egg', 'salty', 'smoked', 'strawberry', 'sugar', 'sweet'] | ||
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 = utils.getRandomIndex(desserts); | ||
return desserts[dessertIndex]; | ||
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 = utils.getRandomIndex(desserts); | ||
const adjectiveIndex = utils.getRandomIndex(adjectives); | ||
return `${adjectives[adjectiveIndex]} ${desserts[dessertIndex]}`; | ||
function generateYummyDessert () { | ||
const dessertIndex = getRandomIndex(desserts) | ||
const adjectiveIndex = getRandomIndex(adjectives) | ||
return `${adjectives[adjectiveIndex]} ${desserts[dessertIndex]}` | ||
} | ||
|
||
exports.generateDessert = generateDessert; | ||
exports.generateYummyDessert = generateYummyDessert; | ||
exports.generateDessert = generateDessert | ||
exports.generateYummyDessert = generateYummyDessert |
Oops, something went wrong.