-
-
Save anonymous/62e3e03cc9bd1c70f1cb02201a7b6b61 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>functions</title> | |
<script language="javascript" type="text/javascript" > | |
function displayBattingAverage() { | |
var hits = parseFloat(prompt("How many times has player hit?" + "")); | |
var bats = parseFloat(prompt("How many times has the player went to bat?" + "")); | |
var displayBattingAverage = hits/bats | |
if (displayBattingAverage > "") { | |
document.write("Your batting average is : " + Math.round (displayBattingAverage*1000)/1000); | |
} | |
else { | |
document.write("No input detected!") | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<script language="javascript" type="text/javascript"> | |
displayBattingAverage(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment