-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add 50 words each for easy, medium and hard levels - Generate a random int - Use it to pick a random word - Return null if the input level is incorrect
- Loading branch information
1 parent
593c147
commit 4b0694c
Showing
4 changed files
with
201 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const utils = require('./utils'); | ||
const words = require('./words.json'); | ||
|
||
const MAX_WORD_INDEX = 50; | ||
const wordlevels = ['easy', 'medium', 'hard'] | ||
|
||
const generateWord = (level) => { | ||
if(!wordlevels.includes(level)){ | ||
return null; | ||
} | ||
const randomNumber = utils.generateRandomInt(MAX_WORD_INDEX); | ||
return words[level][randomNumber]; | ||
} | ||
|
||
module.exports = { | ||
generateWord | ||
} |
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,23 @@ | ||
{ | ||
"name": "pic-word-gen", | ||
"version": "1.0.0", | ||
"description": "A word generator for a pictionary game", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sampathBlam/pic-word-gen.git" | ||
}, | ||
"keywords": [ | ||
"pic", | ||
"pic-word" | ||
], | ||
"author": "Sampath Kumar Krishnan <sampathblam@users.noreply.github.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sampathBlam/pic-word-gen/issues" | ||
}, | ||
"homepage": "https://github.com/sampathBlam/pic-word-gen#readme" | ||
} |
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,3 @@ | ||
exports.generateRandomInt = (max) => { | ||
return Math.floor(Math.random() * max); | ||
} |
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,158 @@ | ||
{ | ||
"easy": [ | ||
"Scissors", | ||
"Point", | ||
"Star", | ||
"Tree", | ||
"Airplane", | ||
"Tail", | ||
"Basketball", | ||
"Mouth", | ||
"Telephone", | ||
"Chin", | ||
"Jar", | ||
"Smile", | ||
"Cheek", | ||
"Ear", | ||
"Drum", | ||
"Room", | ||
"Turtle", | ||
"Wings", | ||
"Doll", | ||
"Bird", | ||
"Spider", | ||
"Hopscotch", | ||
"Happy", | ||
"Baby", | ||
"Monkey", | ||
"Pig", | ||
"Jump", | ||
"Crayon", | ||
"Arm", | ||
"Arm", | ||
"Rabbit", | ||
"Book", | ||
"Camera", | ||
"Rock", | ||
"Chicken", | ||
"Robot", | ||
"Drink", | ||
"Balloon", | ||
"Kangaroo", | ||
"Clap", | ||
"Baseball", | ||
"Milk", | ||
"Icecream", | ||
"Circle", | ||
"Book", | ||
"Sneeze", | ||
"Dog", | ||
"Flower", | ||
"Pillow", | ||
"Tree" | ||
], | ||
"medium": [ | ||
"Beg", | ||
"Rollerblade", | ||
"Summer", | ||
"Cow", | ||
"Fang", | ||
"Table tennis", | ||
"Snowball", | ||
"Guitar", | ||
"Alarm", | ||
"Cape", | ||
"Bird", | ||
"Saddle", | ||
"Rain", | ||
"Bike", | ||
"Roof", | ||
"Blind", | ||
"Hoop", | ||
"Violin", | ||
"Coil", | ||
"Goldfish", | ||
"Frankenstein", | ||
"Stairs", | ||
"Dog", | ||
"String", | ||
"Fetch", | ||
"Cage", | ||
"Mailbox", | ||
"Spider man", | ||
"Puppet", | ||
"Penguin", | ||
"Shovel", | ||
"Popcorn", | ||
"Butter", | ||
"Trumpet", | ||
"Haircut", | ||
"Shopping trolley", | ||
"Lipstick", | ||
"Soap", | ||
"Hula", | ||
"Mop", | ||
"Money", | ||
"Food", | ||
"Glue", | ||
"Banana", | ||
"Hot", | ||
"See-saw", | ||
"Jellyfish", | ||
"Scarf", | ||
"Table tennis", | ||
"Snowball" | ||
], | ||
"hard": [ | ||
"Frankenstein", | ||
"Sand", | ||
"Year", | ||
"Stain", | ||
"Vest", | ||
"Swordfish", | ||
"Pizza", | ||
"Softball", | ||
"Party", | ||
"Wrench", | ||
"Hair", | ||
"Spine", | ||
"Beetle", | ||
"Trip", | ||
"Gym", | ||
"Sip", | ||
"Torch", | ||
"Cowboy", | ||
"Carrot", | ||
"Spider web", | ||
"Beggar", | ||
"Lung", | ||
"Basket", | ||
"Flamingo", | ||
"Cuff", | ||
"Dryer", | ||
"Blinds", | ||
"Brain", | ||
"Business", | ||
"Eraser", | ||
"Volcano", | ||
"Whisk", | ||
"Funny", | ||
"Quicksand", | ||
"Trap", | ||
"Sheet", | ||
"Small", | ||
"Mouse", | ||
"Poison", | ||
"Washing", | ||
"Marble", | ||
"Nightmare", | ||
"Vegetable", | ||
"Anger", | ||
"Knot", | ||
"Badge", | ||
"Cramp", | ||
"Doghouse", | ||
"Mirror", | ||
"Softball" | ||
] | ||
} |