Skip to content

Instantly share code, notes, and snippets.

@bitwiser
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitwiser/9139556 to your computer and use it in GitHub Desktop.
Save bitwiser/9139556 to your computer and use it in GitHub Desktop.
html
<!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>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment