Skip to content

Instantly share code, notes, and snippets.

@courtney-scripted
Last active March 1, 2018 20:19
Show Gist options
  • Save courtney-scripted/c6baff2a5bdd7d7a14114d1313c6ce4d to your computer and use it in GitHub Desktop.
Save courtney-scripted/c6baff2a5bdd7d7a14114d1313c6ce4d to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=c6baff2a5bdd7d7a14114d1313c6ce4d

Fill in this funny MadLib puzzle by declaring variables and assigning values to them.

  1. Assign a value to the variable "person" on line two

  2. Declare a variable named noun1 and assign it a value

  3. Declare all of the variables listed on the screen (adjective2, noun2, adjective3, adjective4, pluralNoun, noun3, number1, shapes, food1, food2, number2)

Remember: Noun: Person, place, or thing (Luis, New York, pencil) Plural Noun: More than one person, place, or thing Adjective: Describing word (beautiful, smelly)

<!DOCTYPE html>
<html>
<head>
<title>07.1 Variables Madlib Mayhem</title>
</head>
<body>
<p id="variables">Missing variables:<br></p>
<h1 id="madlib-title"></h1>
<p id="madlib-target"></p>
<script>
function fillMadlib() {
var variables = ["adjective1", "person", "noun1", "adjective2", "noun2", "adjective3", "adjective4", "pluralNoun", "noun3", "number1", "shapes", "food1", "food2", "number2"];
for(var i = 0; i < variables.length; i++) {
if (typeof window[variables[i]] === 'undefined'){
$('#variables').append( "<span>" + variables[i] + "</span> " );
}
}
$("#madlib-target").append("Pizza was invented by a <span>" + adjective1 + "</span> chef named <span>" + person + "</span>. ");
$("#madlib-target").append("To make pizza you need to take a lump of <span>" + noun1 + "</span>, and make a thin, round <span>" + adjective2 + "</span> <span>" + noun2 + "</span>. ");
$("#madlib-target").append("Then you cover it with <span>" + adjective3 + "</span> sauce, <span>" + adjective4 + "</span> cheese, and fresh chopped <span>" + pluralNoun + "</span>. Next, you have to bake it in a very hot <span>" + noun3 + "</span>. When it's done, cut it into <span>" + number1 + "</span> <span>" + shapes + "</span>. ");
$("#madlib-target").append("Some people like <span>" + food1 + "</span> pizza the best, but my favorite is the <span>" + food2 + "</span>pizza. If I could, I would eat pizza <span>" + number2 + "</span>times a day.");
}
</script>
</body>
</html>
{"enabledLibraries":["jquery"],"hiddenUIComponents":["editor.css","console","editor.html"]}
// DECLARE ALL YOUR VARIABLES BELOW
var adjective1="smelly";
var adjective2="pencil";
var person="sophat";
var noun1="turtle";
var noun2="pigeon";
// Now call the fillMadlib function!
fillMadlib();
body {
text-align: center;
font-size: 150%;
}
#variables {
font-size: 20px;
line-height: 200%;
}
#variables span {
background-color: lightGray;
padding: 5px 10px;
}
#madlib-target span {
font-weight: bold;
color: blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment