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
Read More
- JavaScript code to generate dynamic line graphs/charts
- JavaScript code to generate box and whisker charts/graphs
- JavaScript code to create dynamic charts/graphs
- JavaScript code to generate error line graph/graph
- JavaScript code to create box & whisker chart/graph templates with custom colors
- Instructions on running Node JavaScript code in n8n
- Code of chart/bar graph with error combination
- JavaScript code to create OHLC and line chart combo chart template
- JavaScript code that generates Pareto chart template with Index/Data . label
- What is Currying in Javascript? How to use Currying in JavaScript
- The best free Microsoft Word template download websites
- Guide to coding Flappy Bird game using JavaScript
- JavaScript code to create a zoomable chart with Zoom & Pan functionality.
- How to Make a Basic JavaScript Quiz