I am fairly new to javascript and am trying to get the following program to work. I need to have the program run until doubles are reached and then display the number of attempts it took ’till the doubles was reached.
<!doctype html>
<!– roll.html Dave Reed –>
<!– This page counts dice rolls until doubles are obtained. –>
<!– ========================================================== –>
<html>
<head>
<title> Dice Roller </title>
<script type=”text/javascript” src=”
</script>
<script type=”text/javascript”>
function RollUntilDoubles()
// Assumes: outputDiv is available for output
// Results: rolls and displays dice until doubles are obtained
{
var roll1, roll2;
var doubleCount = 0;
while (roll1 != roll2; doubleCount++) { // WHILE NOT DOUBLES,
roll1 = RandomInt(1, 6); // ROLL AGAIN AND DISPLAY AT
roll2 = RandomInt(1, 6); // THE END OF THE PAGE DIVISION
if (roll1 != roll2) {
doubleCount = doublecount + 1;
alert(‘Number of Rolls: ‘ + doubleCount);
}
document.getElementById(‘outputDiv’).innerHTML =
document.getElementById(‘outputDiv’).innerHTML+
roll1+’-‘+roll2+'<br>’;
}
document.getElementById(‘outputDiv’).innerHTML =
document.getElementById(‘outputDiv’).innerHTML+’DOUBLES!’;
}
</script>
</head>
<body>
<h2>Dice Roller</h2>
<input type=”button” value=”Roll until doubles”
onclick=”RollUntilDoubles();”>
<hr>
<div id=”outputDiv”></div>
</body>
</html>