x
 
1
<!DOCTYPE html>
2
<title>My Example</title>
3
4
5
<p id="msg"></p>
6
7
<script>
8
  // Set variables
9
  var myBankBalance = 0;
10
  var output = "";
11
12
  // Do the 'while' loop
13
  while (myBankBalance <= 10) {
14
    output += "My bank balance is now $" + myBankBalance + "<br>";
15
    myBankBalance ++;
16
  }
17
18
  // Output results to the above HTML element
19
  document.getElementById("msg").innerHTML = output;
20
</script>