Monthly Archives: August 2013

HW1- Mad Libs

<!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.

1 Comment

Filed under Homework

50% off e-books!

O’Reilly has a 50% off e-book offer going on right now until September 10. Use code: B2S3

http://oreilly.com/

Leave a comment

Filed under Announcements

Dictator Mad Libs

<!DOCTYPE html>
<html>
<head>
<title>Dictator Mad Libs</title>
</head>
<body>
<script type =”text/javascript”>
var pronoun = “She”;
var verb = “played”;
var noun1 = “guitar”;
var adjective = “like”;
var article = “a”;
var noun2 = “boss”;
var punctuation = “.”;
console.log(pronoun + ” ” + verb + ” ” + noun1 + ” ” + adjective + ” ” + article + ” ” + noun2 + punctuation);
// document.write(pronoun + ” ” + verb + ” ” + noun1 + ” ” + adjective + ” ” + article + ” ” + noun2 + punctuation);

//w3 schools explanation on running a script
//you might be under the impression that madlibs allows for your own creative control. you are wrong. i’m a dictator. you think what i think. you write what i write. think you’ve chosen your own verb? i chose it for you.
var pronoun2 = “you”;
var adj2 = “might”;
var verb2 = “be”;
var preposition = “under”;
var article2 = “the”;
var noun3 = “impression”;
var relativepronoun = “that”;
var pluralnoun = “madlibs”;
var verb3 = “allows”;
var preposition2 = “for”;
var posesivepronoun = “your”;
var adj3 = “own”;
var adverb = “creative”;
var noun4 = “control”;
//var punctuation .
//var pronoun2 you
var verb4 = “are”;
var adj4 = “wrong”;
//var punctuation .
var posesivepronoun2 = “i’m”;
//var article a
var noun5 = “dictator”
//var punctuation .
//var pronoun2 you
var verb5 = “think”;
var adj5 = “what”;
var pronoun3 = “i”;
// var verb5 think
//var punctuation .
//var pronoun2 you
var verb6 = “write”;
//var adj5 what
//var pronoun3 i
//var verb6 write
//var punctuation .
//var verb5 think
var posesivepronoun3 = “you’ve”;
var pastverb = “chosen”;
// var posesivepronoun your
// var adj3 own
var noun6 = “verb”;
var punctuation2 = “?”;
// var pronoun3 i
var pastverb2 = “chose”;
var pronoun4 = “it”;
var preposition3 = “for”;
//var pronoun2 you
//var punctuation .
console.log(pronoun2 + ” ” + adj2 + ” ” + verb2 + ” ” + preposition + ” ” + article2 + ” ” + noun3 + ” ” + relativepronoun + ” ” + pluralnoun + ” ” + verb3 + ” ” + preposition2 + ” ” + posesivepronoun + ” ” + adj3 + ” ” + adverb + ” ” + noun4 + punctuation + ” ” + pronoun2 + ” ” + verb4 + ” ” + adj4 + punctuation + ” ” + posesivepronoun2 + ” ” + article + ” ” + noun5 + punctuation + ” ” + pronoun2 + ” ” + verb5 + ” ” + adj5 + ” ” + pronoun3 + ” ” + verb5 + punctuation + ” ” + pronoun2 + ” ” + verb6 + ” ” + adj5 + ” ” + pronoun3 + ” ” + verb6 + punctuation + ” ” + verb5 + ” ” + posesivepronoun3 + ” ” + pastverb + ” ” + posesivepronoun + ” ” + adj3 + ” ” + noun6 + punctuation2 + ” ” + pronoun3 + ” ” + pastverb2 + ” ” + pronoun4 + ” ” + preposition3 + ” ” + pronoun2 + punctuation);
document.write(pronoun2 + ” ” + adj2 + ” ” + verb2 + ” ” + preposition + ” ” + article2 + ” ” + noun3 + ” ” + relativepronoun + ” ” + pluralnoun + ” ” + verb3 + ” ” + preposition2 + ” ” + posesivepronoun + ” ” + adj3 + ” ” + adverb + ” ” + noun4 + punctuation + ” ” + pronoun2 + ” ” + verb4 + ” ” + adj4 + punctuation + ” ” + posesivepronoun2 + ” ” + article + ” ” + noun5 + punctuation + ” ” + pronoun2 + ” ” + verb5 + ” ” + adj5 + ” ” + pronoun3 + ” ” + verb5 + punctuation + ” ” + pronoun2 + ” ” + verb6 + ” ” + adj5 + ” ” + pronoun3 + ” ” + verb6 + punctuation + ” ” + verb5 + ” ” + posesivepronoun3 + ” ” + pastverb + ” ” + posesivepronoun + ” ” + adj3 + ” ” + noun6 + punctuation2 + ” ” + pronoun3 + ” ” + pastverb2 + ” ” + pronoun4 + ” ” + preposition3 + ” ” + pronoun2 + punctuation);

</script>
</body>
</html>

Screen Shot 2013-08-27 at 9.03.55 PM Screen Shot 2013-08-27 at 9.04.10 PM

1 Comment

Filed under Homework

Homework1

<!DOCTYPE html>
<html>
<head>
<title>My Basic HTML</title>

</head>
<body>
<script type=”text/javascript”>
//this is where javascript lives
//console=command+option+j
var adj1=”magnificent”;
var noun1=”bear”;
var noun2=”boat”;
var verb1=”stand”;
var verbpast=”arrived”
var adv=”anxiously”;

var sentence=”The “+adj1+” “+noun1+” was “+verb1+”ing “+adv+” when the “+noun2+ ” “+verbpast+”.”
console.log(sentence)
</script>
</body>
</html>

1 Comment

Filed under Homework

Week 01: vars in JavaScript

Hello, class! Welcome to CC Lab. Here is the presentation for this week.

week01-js-vars-paweena

*When posting your homework, please select the “Homework” category.*

Leave a comment

Filed under Presentations