-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs26.html
More file actions
39 lines (30 loc) · 779 Bytes
/
js26.html
File metadata and controls
39 lines (30 loc) · 779 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
<!-- examples on control statements-->
<h3>demo on switch case(it is selection statement under control statements)</h3>
<script>
//it supports all datatypes in javascript
let i="ram";
switch(i)
{
case "ram": document.write(`ok<br>`);break;
default:document.write("not<br>");
}
//it sup conditions
let a=40;
switch(a>=0)
{
case true:document.write(`+ve<br>`);break;
case false:document.write(`-ve<br>`);
}
//we can use variables with in "case"
let x=10,y=20,n=10;
switch(n)
{
case x:document.write(`X`);break;
case y:document.write(`Y`);break;
default:document.write(`None`);
}
</script>
<!-- Decision making => 1 statement=> ?: (ternary operator)
DM => n statements => if
== or != => switch
-->