-
Notifications
You must be signed in to change notification settings - Fork 0
/
45.html
55 lines (48 loc) · 1.31 KB
/
45.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!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>Scope, If else</If-else></title>
</head>
<body>
<div class="p">Hello</div>
<script>
// var is global so using same variable twice can cause problem so we use let as it will show the error
// This will show error due to reuse
// let a=6;
// console.log(a);
// let a=8;
// console.log(a);
let a=6;
console.log(a);
//local scope
{
let a=9;
console.log(a);
}
const s="This cannot change";
console.log(s);
// will show error
// s="Change it";
// console.log(s);
let age=31;
if(age>18)
console.log("can vote");
else
console.log("can't vote");
const cup=1;
switch(cup){
case 1:
console.log("Can drink");
break;
case 2:
console.log("Can't drink");
break;
default:
console.log("Default");
}
</script>
</body>
</html>