for loop into while loop
likeray (0)

help, cannot turn for loop into a while loop.

for works well, just need to make an equivalent while

You are viewing a single comment. View All
likeray (0)

re wrote to look like such and nothing happens @mwilki7

<script type ="text/javascript">
function roll(numOfRolls)
// Initalize function variables and a history array
var i=0;

while (i < numOfRolls)
r=RandomInt(1, 6);
rollHist[r-1]++; // rollHist[r] value is incremented
totals+=r i++; // add the value or r to the totals
} // end of for loop

var avg = totals / numOfRolls; // calc the average from the total

document.form1.average.value=avg; // update the text box
// update the roll hits history display
while (c<6)
} // end of function roll