The while Statement
The while statement is a pretest loop. Here's the syntax:
while(expression)
statement
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var i = 0;
while (i < 10) {
i += 2;
document.writeln(i);
}
//2 4 6 8 10
</script>
</head>
<body>
</body>
</html>