QP School

Full Version: JavaScript - While Loop Example
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
let n = 0;
let x = 0;

while(n < 30)
  {
    n++;
    x += n;
    document.write("The value of n is " + n + "<br>");
    document.write("The value of x is " + x + "<br>");
  }