Created
October 14, 2014 00:59
-
-
Save katherineschultz/0fba14b9e45e98e49b57 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/dimana/2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<a href = "#" onclick="calculate()"> | |
Calculate life time supply | |
</a> | |
<br><br> | |
<a href = "#" onclick="favoriteThings()"> Show favorites </a> | |
<script> | |
function calculate (){ | |
var myAge = 41; | |
var myMaxAge = 129; | |
var myCoffeesPerDay = 2; | |
var daysPerYear = 365; | |
var lifetimeSupplyOfCoffee = (myMaxAge - myAge) * daysPerYear * myCoffeesPerDay; | |
console.log("You will need "+lifetimeSupplyOfCoffee+" coffees to last until your old age of "+myMaxAge); | |
if (lifetimeSupplyOfCoffee > 40000){ | |
console.log("Wow! That's a lot!"); | |
} else { | |
console.log("You seem pretty reasonable!"); | |
} | |
} | |
function favoriteThings () { | |
var favorites = ["Dogs", "Cats", "Bears", "Tigers"]; | |
for (var i=0; i<favorites.length; i++) { | |
console.log(favorites[i]); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment