Last active
August 29, 2015 13:56
-
-
Save bitwiser/9139556 to your computer and use it in GitHub Desktop.
html
This file contains hidden or 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> | |
<title>Average Test Scores</title> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<script> | |
var total = 0; | |
var entryCount = 0; | |
var entry; | |
var bestScore = 0; | |
do { | |
entry = prompt("Enter test score\n" + | |
"Or enter 999 to end entries", 999); | |
entry = parseInt(entry); | |
if (entry >= 0 && entry <= 100) { | |
total = total + entry; | |
entryCount++; | |
} | |
if (entry!=999 && entry > bestScore) { | |
bestScore = entry; | |
} | |
else if (entry != 999){ | |
alert("Entry must by a valid number from 0 through 100\n" + | |
"Or enter 999 to end entries"); | |
} | |
} | |
while (entry != 999); | |
var average = total/entryCount; | |
average = parseInt(average); | |
alert("Average score is" + average +" Best Score is = "+bestScore); | |
</script> | |
</head> | |
<body> | |
<section> | |
<h1>This page is displayed after the JavaScript is executed</h1> | |
</section> | |
<p> </p> | |
<p> </p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment