Quotes help make search much faster. Example: "Practice Makes Perfect"
Sunday, October 21, 2012
Codecademy: Sample Solution to "Program your first game!"
//Check if the user is ready to play!
var age = prompt("What's your age?");
if(age >= 18)
{
console.log("You are allowed to play but I take no responsibility!");
}
else
{
console.log("You are encougraged to play on!");
}
console.log("\nSnow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him.");
console.log("\nBatman glares at you.");
var userAnswer = prompt("\nAre you feeling lucky, punk?");
if(userAnswer === "yes")
{
console.log("\nBatman hits you very hard. It's Batman and you're you! Of course Batman wins!");
}
else
{
console.log("\nYou did not say yes to feeling lucky. Good choice! You are a winner in the game of not getting beaten up by Batman.");
}
//feedback
var feedback = prompt("How would you rate the game on a scale of 1 to 10, 10 being the highest?");
if(feedback > 8)
{
console.log("This is just the beginning of my game empire. Stay tuned for more!");
}
else
{
console.log("I slaved away at this game and you gave me that score?! The nerve! Just you wait!");
}
Subscribe to:
Comments (Atom)
This is an example of scrolling text using Javascript.
Popular Posts
-
#sample solution pyg = 'ay' original = raw_input('Enter a word:') if len(original) > 0 and original.isalpha(): p...
-
A typical compounding problem would be something like: How much is the equivalent Present Value (P) if an investment pays an amount (A...
-
A typical compounding problem would be something like: How much will I get annually (A) starting next year if I invest a present value...
-
<style> p { font-family: sans-serif; font-size:18px;} div#welcome p{ font-family: cursive; font-size: 24px; color: white; b...
-
A typical compounding problem would be something like: What is the present value (P) of a future value (F) if (P) was deposited/lent a...
-
// Sample solution // Write a string rotation method. // It should pass all the tests given below. String.prototype.rotate = function(n...
-
A typical compounding problem would be something like: What is the future value (F) of a present value (P) deposited/lent at an intere...
-
<style> #content p {color: yellow;} p {color: purple;} p {color: green;} </style> <div id="content...
-
#sample solution class Triangle(object): #member variables number_of_sides = 3 #methods def __init__(self, angle1, angle2, angle...
-
#sample solution class Shape(object): """Makes shapes!""" def __init__(self, number_of_sides): self....