<!DOCTYPE html>
<html>
<body>
<p>Click the button to create a sentence.</p>
<button onclick=”myFunction1()”>Get Started!</button>
<p id=”madLib”></p>
<script type= “text/javascript”>
//I found help with the prompt() function here: http://www.w3schools.com/jsref/met_win_prompt.asp
function myFunction1()
{
var newSentence;
var adjective1 = “fat”;
var adverb1 = “loudly”;
var verb1 = “waddles”;
var verb2 = “laugh”;
var noun1 = “toilet”;
var noun2 = “dog”;
var sentence = “The “+adjective1+” “+noun2+” “+verb1+” to the “+noun1+”. It made me “+verb2+” “+adverb1+”.”;
console.log(sentence);
var adjective2=prompt(“Please enter an adjective”,”fat”);
var adverb2=prompt(“Please enter an adverb”,”loudly”);
var verb1a=prompt(“Please enter an verb”,”waddles”);
var verb2a=prompt(“Please enter an verb”,”laugh”);
var noun1a=prompt(“Please enter an noun”,”toilet”);
var noun2a=prompt(“Please enter an noun”,”dog”);
// document.write (“The “+adjective2+” “+noun2a+” “+verb1a+” to the “+noun1a+”. It makes me “+verb2a+” “+adverb2+”.”);
if (adjective2!=null)
{
newSentence=”The “+adjective2+” “+noun2a+” “+verb1a+” to the “+noun1a+”. It makes me “+verb2a+” “+adverb2+”.”
document.getElementById(“madLib”).innerHTML=newSentence;
}
console.log(newSentence);
}
</script>
</body>
</html>
//This prompt function is cool. I will continue working on how to allow a button for each word change only that word.