-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch.html
More file actions
45 lines (38 loc) · 963 Bytes
/
switch.html
File metadata and controls
45 lines (38 loc) · 963 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var name = 'ben';
var sex = 'male';
switch (sex) {
case 'male':
alert(name + '先生,你好');
break;
case 'female':
alert(name + '女士,你好');
break;
}
//判断单双数
var a = 12;
// if(a%2==0){
// alert('双数');
// }else{
// alert('单数');
// }
a % 2 == 0 ? alert('双数') : alert('单数');
//for循环的使用
for (var i = 0; i < 5; i++) {
if (i == 2) {
break;//中断整个循环
continue;//中断本次循环
}
alert(i);
}
</script>
</head>
<body>
</body>
</html>