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:
Posts (Atom)
This is an example of scrolling text using Javascript.
Popular Posts
-
var my_canvas=document.getElementById('canvas'); var context=my_canvas.getContext('2d');
-
This is caused by the entrance of water into the air sacs which makes the lungs doughy, readily pits on pressure, exuding water and froth
-
Question: What current is required for full scale deflection of a galvanometer having a current sensitivity of 50 micro-amperes per scale di...
-
#sample solution print "What's your first name?" first_name = gets.chomp.capitalize! print "What's your last na...
-
//Sample Solution const gameState = {} function preload() { this.load.image('codey', 'https://s3.amazonaws.com/codecademy-...
-
#Sample Solution --- title: "Data Cleaning in R" output: html_notebook --- ```{r message=FALSE, warning=FALSE} # load libra...
-
Solution: SELECT first_name, age, FROM table_name;
-
# Update data types year_1_str = str(year_1) revenue_1_str = str(revenue_1) # Create a complete sentence combining only the string d...
-
#sample solution secret_identities = { "The Batman" => "Bruce Wayne", "Superman" => "Clark Ke...
-
Answer: This is the type of injury when a blow to the forehead causes a contusion of the eyeball due to the fracture of the bone at the r...