<html>
<head>
<title>Using the while Loop in JavaScript</title>
</head>
<body>
<script type="text/javascript">
<!--
var i = 0;
var result = 0;
var status = true;
document.write("0");
while(status){
result += ++i;
document.write(" + " + i);
if(i == 10){
status = false;
}
}
document.writeln(" = " + result);
// -->
</script>
</body>
</html>
|