Skip to content

Instantly share code, notes, and snippets.

@aetweedie
Forked from matthaxby/index.html
Last active August 29, 2015 14:20
Show Gist options
  • Save aetweedie/98cda32276a996112448 to your computer and use it in GitHub Desktop.
Save aetweedie/98cda32276a996112448 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var orcA = {
name: "walrus",
strength: 10,
specialMove: "epic mustaches",
health: 100
};
var orcB = {
name: "Mango",
strength: 20,
specialMove: "sticky punches",
health: 100
};
var fight = function(orcA, orcB, healthA, healthB) {
healthA = healthA - orcB.strength;
healthB = healthB - orcA.strength;
console.log(orcA.name + " " + orcA.specialMove + " " + orcB.name + " Health at" + healthB);
console.log(orcB.name + " " + orcB.specialMove + " " + orcA.name + " Health at" + healthA);
if(healthA <= 0) {
return orcA.name + "is dead";
}
else if (healthB <= 0) {
return orcB.name + "is dead";
}
else {
return fight(orcA, orcB, healthA, healthB);
}
};
console.log(fight(orcA, orcB, orcA.health, orcB.health));
/* if( orcA.strength > orcB.strength ) {
return orcA.name + " " + orcA.specialMove + " " + orcB.name + " to DEATH!";
}
else if(orcA.strength < orcB.strength) {
return orcB.name + " " + orcB.specialMove + " " + orcA.name + " to DEATH!";
}
else {
return "It's a TIE";
}/*
};
console.log(fight(orcA, orcB));*/
</script>
<script id="jsbin-source-javascript" type="text/javascript">
var orcA = {
name: "walrus",
strength: 10,
specialMove: "epic mustaches",
health: 100
};
var orcB = {
name: "Mango",
strength: 20,
specialMove: "sticky punches",
health: 100
};
var fight = function(orcA, orcB, healthA, healthB) {
healthA = healthA - orcB.strength;
healthB = healthB - orcA.strength;
console.log(orcA.name + " " + orcA.specialMove + " " + orcB.name + " Health at" + healthB);
console.log(orcB.name + " " + orcB.specialMove + " " + orcA.name + " Health at" + healthA);
if(healthA <= 0) {
return orcA.name + "is dead";
}
else if (healthB <= 0) {
return orcB.name + "is dead";
}
else {
return fight(orcA, orcB, healthA, healthB);
}
};
console.log(fight(orcA, orcB, orcA.health, orcB.health));
/* if( orcA.strength > orcB.strength ) {
return orcA.name + " " + orcA.specialMove + " " + orcB.name + " to DEATH!";
}
else if(orcA.strength < orcB.strength) {
return orcB.name + " " + orcB.specialMove + " " + orcA.name + " to DEATH!";
}
else {
return "It's a TIE";
}/*
};
console.log(fight(orcA, orcB));*/
</script></body>
</html>
var orcA = {
name: "walrus",
strength: 10,
specialMove: "epic mustaches",
health: 100
};
var orcB = {
name: "Mango",
strength: 20,
specialMove: "sticky punches",
health: 100
};
var fight = function(orcA, orcB, healthA, healthB) {
healthA = healthA - orcB.strength;
healthB = healthB - orcA.strength;
console.log(orcA.name + " " + orcA.specialMove + " " + orcB.name + " Health at" + healthB);
console.log(orcB.name + " " + orcB.specialMove + " " + orcA.name + " Health at" + healthA);
if(healthA <= 0) {
return orcA.name + "is dead";
}
else if (healthB <= 0) {
return orcB.name + "is dead";
}
else {
return fight(orcA, orcB, healthA, healthB);
}
};
console.log(fight(orcA, orcB, orcA.health, orcB.health));
/* if( orcA.strength > orcB.strength ) {
return orcA.name + " " + orcA.specialMove + " " + orcB.name + " to DEATH!";
}
else if(orcA.strength < orcB.strength) {
return orcB.name + " " + orcB.specialMove + " " + orcA.name + " to DEATH!";
}
else {
return "It's a TIE";
}/*
};
console.log(fight(orcA, orcB));*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment