forked from ProgrammerZamanNow/belajar-javascript-dasar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch-statement.html
39 lines (35 loc) · 946 Bytes
/
switch-statement.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Switch Statement</title>
</head>
<body>
<script>
const nilai = "E";
switch (nilai) {
case "A":
document.writeln("<p>Wow Anda Lulus Dengan Baik</p>");
break;
case "B":
case "C":
document.writeln("<p>Anda Lulus</p>");
break;
case "D":
document.writeln("<p>Anda Tidak Lulus</p>");
break;
default:
document.writeln("<p>Mungkin Anda Salah Jurusan</p>");
}
if (nilai === "A") {
document.writeln("<p>Wow Anda Lulus Dengan Baik</p>");
} else if (nilai === "B" || nilai === "C") {
document.writeln("<p>Anda Lulus</p>");
} else if (nilai === "D") {
document.writeln("<p>Anda Tidak Lulus</p>");
} else {
document.writeln("<p>Mungkin Anda Salah Jurusan</p>");
}
</script>
</body>
</html>