How to Code a Phrasal Template Word Game Using Javascript
Phrasal word template games are game in which the player fills in a random part of speech, not knowing what it will be applied to. The most popular example of this is MadLibs. This is a fun game to code and play, and you will be proud once...
Method 1 of 2:
Setting Up the Story Template
- Use a Notepad-type program or application to write up a story. Do not add in the blanks just yet.
- Example: One sunny day, Tom went to the grocery store to buy some ham. When he got home, he discovered that his sister had already bought some ham while he was gone.
- Add in the blanks. You may add in blanks where there are names, places, nouns, adjectives, verbs, adverbs, prepositions, numbers, animals, body parts, foods, etc.
- Example: One (Adjective) day, (Male Name) went to the (Place) to (Verb) some (Plural Food). When he got home, he (Past Tense Verb) that his (Family Member) had already bought some (Same Plural Food) while he was gone.
- Convert your new story into code. The variables will be defined in the next step, so don't worry about them just yet.
- Example: alert ('One ' + adj + ' day, ' + maleName + ' went to the ' + place + ' to ' + verb + ' some ' + pluralFood + '. When he got home, he ' + pastVerb + ' that his ' + famMember + ' had already bought some ' + sameFood + ' while he was gone. ')
Method 2 of 2:
Setting Up the Variables to Fill in the Blanks
- Code the variables using prompts. For each one, type "var nameOfVble = prompt ('Type a name of variable below. ')", replacing "nameOfVble" and "name of variable" with the part of speech. Replace "a" with "an" if necessary.
- Example:
- var adj = prompt ('Type an adjective below! ')
- var maleName = prompt ('Type a male name below! ')
- var place = prompt (Type a kind of place below! ')
- And so on.
- Add in the story code.
- Example:
- var adj = prompt ('Type an adjective below! ')
- var maleName = prompt ('Type a male name below! ')
- var place = prompt ('Type a kind of place below! ')
- var verb = prompt ('Type a verb below! ')
- var pluralFood = prompt ('Type a plural food below! ')
- var pastVerb = prompt ('Type a past tense verb below! ')
- var famMember = prompt ('Type a kind of family member below! ')
- var sameFood = prompt ('Type the word ' + pluralFood + ' below! ')
- alert ('One ' + adj + ' day, ' + maleName + ' went to the ' + place + ' to ' + verb + ' some ' + pluralFood + '. When he got home, he ' + pastVerb + ' that his ' + famMember + ' had already bought some ' + sameFood + ' while he was gone. ')
4 ★ | 2 Vote
You should read it
- How to Create a Custom Windows Command Prompt
- Try Google: When did Google become a verb?
- How to Watch Star Wars on Command Prompt
- How to use the command history function in Command Prompt
- Windows prompt
- How to customize the Command Prompt on Windows
- Add Command Prompt to Power User Menu on Windows 10
- How to Make Command Prompt Appear at School
- 6 Best Command Prompt Alternatives for Windows
- How to open Command Prompt on Windows 10, 8, 7, Vista and XP
- All Frequency Restart, Shutdown, Remote Off ... with Command Prompt
- Data type in C #
Maybe you are interested
The surprising truth is that many Gen Zers don't know how to type with 10 fingers.
If you're not already using this type of keyboard, it's time to switch!
This WhatsApp feature saves you from having to retype messages
Don't build a smart house without these 4 types of devices!
This is the type of password that takes 34,000 years to crack
What type of smartphone camera grid is best?