Last active
August 29, 2015 13:57
-
-
Save benwillkommen/9607702 to your computer and use it in GitHub Desktop.
This file contains 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
<html> | |
<head> | |
<title>My Site!</title> | |
<script src="main.js"></script> | |
</head> | |
<body> | |
<a id="link" href="#" onclick="calculate()">asdf</a> | |
</body> | |
</html> |
This file contains 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
function myFriends(){ | |
//declare array of friend objects, with your friends name and hair color | |
var friends = []; | |
var message = ""; | |
//iterate over the friends array using a for loop | |
for(/* loop stuff */){ | |
//build descriptive message here | |
} | |
alert(message); | |
} | |
function favoriteThings(){ | |
var myFavoriteThings = ["javascript", "game of thrones", "squaresoft RPGs", "lifting heavy things"]; | |
var message = "My favorite things are "; | |
for (var i = 0; i<myFavoriteThings.length; i++){ | |
if(i == myFavoriteThings.length-1){ | |
message = message + " and " + myFavoriteThings[i] + "."; | |
} | |
else{ | |
message = message + myFavoriteThings[i] + ", "; | |
} | |
} | |
alert(message); | |
} | |
function calculate(){ | |
var age = 27; | |
var deadAt = 138; | |
var proteinDustPerDay = 3; | |
var totalDustIntake = (deadAt - age) * 365 * proteinDustPerDay; | |
var message = ""; | |
if(totalDustIntake > 40000){ | |
message = 'wow, that\'s alot of dust!'; | |
} | |
else { | |
message = "that's a reasonable amount of dust."; | |
} | |
alert(message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment