I am practicing with while loops for an assignment and trying to use Math.random to generate a loop with 10 iterations, so I get a random number every time. Instead I keep getting the same number listed 10 times in a row. Not sure what I'm doing wrong here? Using in the HTML to display all the results at once.
<script type="text/javascript">
var x = 0;
function showResults() {
var randomNum = Math.floor(Math.random() * 999) + 1;
loopOutput = "";
while (x < 10) {
x++;
document.getElementById("loopResults").innerHTML += "<p>Our answer: " + x + ". " + randomNum + "</p>";
}} //end function showResults()
</script>