-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJS5.html
More file actions
93 lines (76 loc) · 2.52 KB
/
JS5.html
File metadata and controls
93 lines (76 loc) · 2.52 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scope and Conditionals</title>
</head>
<body>
<div>
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
<li>item7</li>
</ul>
</div>
<script>
var string1 = 'This is a String';
var string1 = 'This is a String2';
console.log(string1)
// scope of this is block level we can use same variale in the block {} from now we are going to use let only for global or function or normall
// We are using let insteat of var for we know that in future coming we need to change the variable or add new variable so because of that we are let
// let a = 'u';
// {
// let a = 'u6';
// console.log(a)
// }
// console.log(a)
// Now we are going to see cons that is constant and constant means that thing cant be changed
const a = 'This cannot be changed';
// a = 'I want to change this '
// so here this a changed will not happen due to we have select the constant const var for write our string
console.log(a)
// Here we are going to understand the if else statement
let age = 14;
if(age > 18){
console.log('You are an adult')
}
else if(age==2){
console.log('You are a baby')
}
else if(age==14){
console.log('You are an Teenager')
}
else{
console.log('You are not an adult')
}
// Switch case statements
const cups = 10 ;
switch (cups) {
case 4:
console.log('The value of cups is 4')
break;
case 10:
console.log('The value of cups is 10')
break;
case 8:
console.log('The value of cups is 8')
break;
case 30:
console.log('The value of cups is 30')
break;
case 33:
console.log('The value of cups is 33')
break;
default:
console.log('The value of cups is none of them')
break;
}
// if we remove all the breaks then it will run akl the cases by default
</script>
</body>
</html>