In the following script (I’m trying to get away from using forms), each click should put a new test on the next line, but the output just continues at the end of the previous line. What am I missing? The newlines seem to be ignored.
[code]<!DOCTYPE html>
<html lang=”en”>
<head>
<title>Spider Solitaire</title>
<script>
function sortCards(a,b) {return a – b;}
function genform() {
var deck = new Array(104);
var shuffle = new Array;
var countNull = 0;
for (var m = 0; m < 10000; m++) {
for (var i=0; i < 104;i++) { // New game done 1000 times
deck[i] = i % 13; // Will repeat 0 – 12 eight times
}
var j = 104;
for (var n = 0; n < 5;n++) { // Will draw five times per game}
var haveMove = false;
for (var k = 0; k < 10; k++) {
var r = Math.floor(Math.random() * (j+1)); // Pick one from those remaining
shuffle[k] = deck[r];
j–; }
shuffle.sort(sortCards);
for (var mm = 0;mm < 9;mm++) {
if (haveMove) break;
for (var nn=mm+1;nn < 10;nn++) {
if (haveMove) break;
if (Math.abs(shuffle[mm] – shuffle[nn]) == 1) {
haveMove = true;
break;}
} }
if (!haveMove) countNull++;
}
}
document.body.innerHTML+=” Number of null moves in 10000 games (50000 draws) ” + countNull + “rn”;
}
</script>
</head>
<body>
<h1>Spider Solitaire test</h1>
<input type=”button” value=”Run Again” onClick=”genform();”>
<br>
</body>
</html