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)

thank you I plugged in and it looked like this, however, still getting all 0s

<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 should be while (i < numOfRolls) { r=RandomInt(1, 6); rollHist[r-1]++; // rollHist[r] value is incremented totals+=r; // add the value or r to the totals i++; } // end of for loop </script>

@mwilki7