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 var yourName = "Pam"; var gender = "female"; var result; //Line 10 starts an if statement //Ne...
-
//sample solution def isEven(x): if(x % 2 == 0): return "yep" else: return "nope"
-
#sample solution hungry = false unless hungry puts "I'm writing Ruby programs!" else puts "Time to eat!...
-
Answer: Alt - p p stands for previous. If you keep pressing Alt - p, you will continue cycling back through commands you typed before. I...
-
<!--sample solution--> <html> <head> <title>Week 13 Project</title> </head> ...
-
<!-- Sample solution to index.html --> <!DOCTYPE html> <html> <body> <div class="nav"> ...
-
<html> <head> <!-- Add the Parse SDK here! --> <script src="http://www.parsecdn.com/js/par...
-
class Computer @@users = {} def Computer.get_users return @@users end def initialize(username, password) @username = usern...
-
# Test equality test_company = 'apple' print(company_1 == test_company) # Compare revenue_1 and revenue_2 print(revenue_1 ...
-
// sample solution to script.js $(document).ready(function() { $("ul.tabs li").click(function(){ var pageID = $(t...