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
    if (myBankBalance === 5) { 
15
      break; 
16
      }
17
    output += "My bank balance is now $" + myBankBalance + "<br>";
18
    myBankBalance ++;
19
  }
20
21
  // Output results to the above HTML element
22
  document.getElementById("msg").innerHTML = output;
23
</script>