-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditional statements.html
More file actions
81 lines (64 loc) · 1.77 KB
/
conditional statements.html
File metadata and controls
81 lines (64 loc) · 1.77 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
<!-- if else -->
<script>
var emoji = String.fromCodePoint(0x1F923);
let colour=prompt("What is Your Favourite Colour ?");
if(colour!=="black"){
document.write("ugly colour"+ emoji);
}else{
document.write("Superb Colour"+ String.fromCodePoint(0x1F929));//you can also write like this
}
</script>
<!-- Switch Case -->
<script>
let fruits=prompt("Enter your favourite Fruits Name !!");
switch(fruits){
case "mangoes" : document.write("They are Yellow in Colour!");
break;
case "watermelon" : document.write("They are Red in Colour!");
break;
case "litchi" : document.write("They are White in Colour");
break;
default : document.write("Please Enter Valid Fruit Name");
}
</script>
<!-- Sum of first n Natural Numbers -->
<script>
let sum=0;
let n=prompt("Enter the value of "+"n");
for(let i=0;i<n;i++){
sum+=(i+1);
}
document.write("The sum of first "+n+" natural number is : "+sum);
</script>
<!-- for in loop -->
<script>
let marks={
"ROLEX" : 100,
"DILLI" : 90,
"VIKRAM" : 80,
"AMAR" : 70,
"SANDHANAM" : 60,
"ANBU" : 50,
"ADAIKALAM" : 40
}
for(let a in marks){
document.write("The Total Marks of "+a+" is : "+marks[a]);
document.write("<br/>")
}
</script>
<!-- for of -->
<script>
for(let x of "AMARENDRA BAHUBALI"){
document.write(x);
document.write("<br/>");
}
</script>
<!-- while loop -->
<script>
let i=0;
while(i<20){
document.write("I"+String.fromCodePoint(0x1F47D)+"U");
document.write("<br/>");
i++;
}
</script>