For this project, I decided to create a MadLib generator! While most MadLibs require the user to supply their own nouns, adjectives, etc., I wanted this program to randomly select its own from a pre-defined list. The user can add their own or replace mine entirely. This creates tons of random funniness!
I had a lot of fun creating this program! My favorite part is creating the sentences used by the generator, even though I’m not very good at coming up with funny sentences. Please do us both justice and replace mine with your own
HOW LONG DID IT TAKE?
The project took around 3-4 days to complete, including documentation. I work two jobs, so the amount of time I had available was fairly sparse.
WHAT DID I LEARN?
To parse the sentences, this project makes use of regular expressions, which I’m not very adept at. So, I used https://regex101.com/ and toyed around with the documentation and eventually learned the regular expression to locate what I call “tags” (text between square brackets, such as
For anybody wanting to know, the pattern is:
Math.random() to choose random nouns, adjectives, verbs, etc. as well as choose random sentences to present to the user.
case 'food': this._values.push(food[Math.floor(Math.random() * food.length)]) break
HOW DID I DO?
Let me know how I did Much can be improved in the code, I am sure. Maybe someday I can code along with someone and learn even more. Thanks for checking this out!