Project Outcomes:

Write a JavaScript program that uses:

  • Variables to hold user-provided values
  • Functions to gather data from the user and compute data

Prep Readings:

JavaScript and jQuery, Chapters 1 through 3.

Project Requirements:

1.Write a program that generates mad libs based on input from the user. The program will ask the user for their first name and then use that name to greet the user. It will then prompt the user for at least four different types of words and generate a mad lib sentence or paragraph based on the user's input.

2.The program should use a function to get the user's first name. It will then output a greeting to the user directly from the function. (See the example below.)

3.You are required to use a function to gather the words from the user used to fill in the blanks of the mad lib. Write a function that takes in a string representing the category of the word (ex: "noun", "adjective", etc.). The function should then use a prompt() to ask the user to input a word of that type. The function should then return what the user entered. For example, if you pass in the string "noun" to the function, the function should ask the user "Please enter a noun." and return the string that they entered.

4.Generate a mad-lib by calling the function multiple times and storing the returned words in variables. You can stitch together the variables along with string values to make a mad lib. See this website for an example of some Mad Libs that you can use. Feel free to be creative: http://www.redkid.net/madlibs/

Example:

Prompt: "Welcome to the Mad Lib program. What's your name?"
Input "Bill"
Alert: "Pleased to meet you, Bill! Let's get started."
Prompt: "Please enter an exclamation:"
Input: "ouch"
Prompt: "Please enter an adverb:"
Input: "stupidly"
Prompt: "Please enter a noun:"
Input: "cat"
Prompt: "Please enter an adjective:"
Input: "brave"
Alert: Here's your madlib! "ouch! he said stupidly as he jumped into his convertible
cat and drove off with his brave wife."
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.