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
-
Question: The total power dissipation in an RL series circuit is due to which component? Answer: The total power dissipation is due to ...
-
Type in the length of the shorter base of the trapezoid: meters Type in the length of the longer base of the trapezoid: meters ...
-
A regular polygon has sides of equal length. Type in the length of the side of a sided regular polygon: meters Compute
-
Type in the length of the side of a dodecagon: meters Compute
-
Type in the length of the side of a myriagon: meters Compute
-
This script will try to solve for x in a system of linear equations of the form Ax=y . x is the unknown column vector and y is th...
-
//sample solution function additionWithoutCarrying(param1, param2) { var param1Array = param1.toString().split("").reverse()...
-
#sample solution m = 5 n = 13 #function goes here def myFun(*x): sum = 0 for index in range(0,len(x)): sum = sum + x[index] r...
-
Say you had an election, and you needed to tally the votes for each candidate. All you need to do is enter the name of each candidate o...
-
#Sample Solution --- title: "Quantiles" output: html_notebook --- ```{r} # load song data load("songs.Rda") ```...