-
-
Save aetweedie/98cda32276a996112448 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
<!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> |
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
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