-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIf-Expression.html
More file actions
33 lines (27 loc) · 991 Bytes
/
If-Expression.html
File metadata and controls
33 lines (27 loc) · 991 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
<!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>Learn If expression</title>
</head>
<body>
<script>
const examValue = 91;
if (examValue >= 90) {
document.writeln(`<h1>Perfect : ${examValue}</h1>`);
} else if (examValue >= 80 && examValue < 90) {
document.writeln(`<h1>Good Job : ${examValue}</h1>`);
} else if (examValue >= 70 && examValue < 80) {
document.writeln(`<h1>Not Bad ${examValue}</h1>`);
} else {
document.writeln(`<h1>Try again Next Week</h1>`)
}
// How to use Ternary Operator
// variabel = condition ? condition true : condition false
let ucapan = examValue >= 80 ? "Good Job Boy" : "Next Try";
document.writeln(`<h1>Good Job : ${ucapan}</h1>`);
</script>
</body>
</html>