-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path31.while-loop.html
More file actions
51 lines (47 loc) · 770 Bytes
/
31.while-loop.html
File metadata and controls
51 lines (47 loc) · 770 Bytes
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
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>While Loop</title>
</head>
<body>
<script>
let counter = 1;
while (counter <= 10) {
document.writeln(`<p>Perulangan ke ${counter}</p>`);
counter++;
}
let i = 1;
while (i <= 10) {
console.log(i);
i++;
}
/*
Output:
1
2
3
4
5
6
7
8
9
10
*/
let angka = [];
// Tulis kode kalian di bawah ini
let urut = 5;
while (urut >= 0) {
angka.push(urut);
urut--;
console.log(angka);
}
// 0:5
// 1:4
// 2:3
// 3:2
// 4:1
</script>
</body>
</html>