Skip to content

Instantly share code, notes, and snippets.

@benwillkommen
Last active August 29, 2015 13:57
Show Gist options
  • Save benwillkommen/9607702 to your computer and use it in GitHub Desktop.
Save benwillkommen/9607702 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>My Site!</title>
<script src="main.js"></script>
</head>
<body>
<a id="link" href="#" onclick="calculate()">asdf</a>
</body>
</html>
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