Access over 35 million academic & study documents

2 3 Make your own Mad Lib In this exercise you will create a Web p

Content type
User Generated
Showing Page:
1/3
2_3. Make your own Mad Lib: In this exercise you will
create a Web page that serves as an interactive Mad Lib
program. Your page will contain JavaScript code that
prompts the user for words to fill in the blanks in a story,
and then stores those words in variables. After having read
in all of the words, your code should then display the story
in the Web page, using the values of the variables where
appropriate. For example, here is a start to a Mad Lib:
Solution
Hi,
Below is the solution to your question:
<html>
<!-- madlib.html -->
<!-- -->
<!-- Web page that is used to display a Lib story. -->
<!----------------------------------------------------->
<head>
<title> Mad Lib </title>
</head>
<body>
<script type=\"text/javascript\">

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/3
adjective = prompt(\"Enter an adjective\", \"beautiful\");
boy = prompt(\"Enter the name of the boy\", \"Adam\");
color = prompt(\"Enter the color\", \"blue\");
swear = prompt(\"Enter a swear word or exclamation\",
\"Damn!\");
animal = prompt(\"Enter a type of animal\", \"Cat\");
building = prompt(\"Enter a type of building\",
\"coffeeshop\");
document.write(\"<center><h1>A Typical Day</h1>\" +
\"<h3>By name</h3></center>\" +
\"<hr />\");
document.write(\"<p>It was a \" + adjective + \" kind of day
when \" + boy +
\" walked out into the street. The sky was a deep \" + color
+
\" and \" + boy + \" was walking his pet \" + animal +
\".</p>\");
document.write(\"<p>\'\" + swear +\"\' exclaimed \" + boy +
\" as he stepped off\" +
\" the curb and into a large pile of \" + animal + \"
excrement.\" +
\" \'I think I\'ll just go find a nice \" + building + \", crawl
in,\" +
\" and go back to sleep.\'</p>\");
</script>

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/3

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
2_3. Make your own Mad Lib: In this exercise you will create a Web page that serves as an interactive Mad Lib program. Your page will contain JavaScript code that prompts the user for words to fill in the blanks in a story, and then stores those words in variables. After having read in all of the words, your code should then display the story in the Web page, using the values of the variables where appropriate. For example, here is a start to a Mad Lib: Solution Hi, Below is the solution to your question: Mad Lib adjective = prompt(\"Enter an adjective\", \"beautiful\"); boy = prompt(\"Enter the name of the boy\", \"Adam\"); color = prompt(\"Enter the color\", \"blu ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4