-
Notifications
You must be signed in to change notification settings - Fork 0
/
BTswitchcase.html
41 lines (41 loc) · 1.11 KB
/
BTswitchcase.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">
<title>Switch case</title>
</head>
<body>
<h2>Tinh so ngay trong 1 thang:</h2>
<p><input type="number" id="a"> <button onclick="tinhsongay()">Tinh so ngay</button></p>
<br>
<div><strong id="KQ"></strong> </div>
</body>
</html>
<script>
function tinhsongay() {
let a = +document.getElementById('a').value;
let b;
switch (a) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
document.getElementById('KQ').innerHTML = 'Thang ' + a + ' co 31 ngay';
break;
case 4:
case 6:
case 9:
case 11:
document.getElementById('KQ').innerHTML = 'Thang ' + a + ' co 30 ngay';
break;
case 2:
document.getElementById('KQ').innerHTML = 'Thang ' + a + ' co 28 hoac 29 ngay';
break;
default:
document.getElementById('KQ').innerHTML = 'Nhap sai';
}
}
</script>