-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWhile-Loop.html
41 lines (35 loc) · 962 Bytes
/
While-Loop.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>While Loop</title>
</head>
<body>
<script>
let varLoop = 1;
while (varLoop <= 7) {
document.writeln(`${varLoop}`);
varLoop++;
}
// continue and Break
let thisBreak = 1
while (true) {
document.writeln(`<p>${thisBreak}</p>`);
thisBreak++;
if (thisBreak > 5) {
break;
}
}
let thisContinue = 0;
while (thisContinue <= 10) {
thisContinue++;
if (thisContinue % 2 === 0) {
continue; // menghentikan eksekusi saat ini, lalu lanjutkan lagi loopny
}
document.writeln(`${thisContinue}`);
}
</script>
</body>
</html>