-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.js
More file actions
145 lines (105 loc) · 3.41 KB
/
sample.js
File metadata and controls
145 lines (105 loc) · 3.41 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
let firstName = "Sudip"
let lastName = "Dadhaniya"
let age = "33"
let gender = "Male"
document.write("Hello!!")
document.write(firstName , lastName)
console.log(firstName , lastName )
document.write("<br>")
document.write("*****************************************")
document.write("<br>")
/*** If Statement ***/
if(age <= 13){
document.write("You are Child!!")
}
else if(age >= 18){
document.write("You are Adult ")
}
else{
document.write("You are Teenager!!")
}
/*** If Statement BMI Calculator ***/
document.write("<br>")
let val=bmiCalculator(74,175); //Enter Weight in Kg and Height in cm
if(val < 18.5){
document.write("Your BMI is "+val+": You are Underweight");
} else {
if ( val >= 18.5 && val <= 24.9) {
document.write("Your BMI is "+val+": You have a Normal Weight");
} else {
if ( val > 24.9) {
document.write("Your BMI is "+val+": You are Overweight");
}
}
}
function bmiCalculator (weight, height) {
return ( Math.round((weight/(height*height))*10000));
}
document.write("<br>")
/*** Switch Statement ***/
switch (true) {
case (age >= 0 && age <=10):
document.write("Your Age is NOT between 0 and 10 <br />");
break;
case age >= 0 && age <= 10:
document.write("Your Age is between 0 and 10 ");
break;
case age >=80 && age <=10:
document.write("Your Age is 80 or above or 10 or below ");
break;
case age >= 30 && age <=39:
document.write("Your Age is between 30 and 39 ");
break;
case age >= 80 && age <= 89:
document.write("Your Age is between 80 and 89 ");
break;
default:
document.write("Enter Valid age");
}
document.write("<br>")
/*** For Loop ***/
document.write("Numbers :")
for (i=1; i<=10; i++){
document.write(+i, ",");
}
document.write("<br>")
let hobbies = ['Playing Cricket','Watching Movie','Travelling'];
let x;
document.write("Hobbies :")
for (x of hobbies){
document.write(x,",");
}
document.write("<br>")
/*** While Loop ***/
let counter = 1;
document.write("Counter Numbers :")
while(counter <=10){
document.write(+counter, ",");
counter=counter+1;
}
document.write("<br>")
/*** Array ***/
let numbers = [1, 2, 3, 4, 5, 6, 7];
document.write("Array Numbers :", numbers, "<br>" )
let fruits = ['Apple', 'Banana', 'Grapes'];
let cars = new Array('Ford', 'Toyota', 'Jeep');
document.write("Array length of Fruits is :", fruits.length, "</br>")
cars[1] = 'Honda';
document.write("Fruits :", fruits, "</br>")
fruits.push('Cherry');
document.write("Add Cherry in Fruits :", fruits, "<br>")
document.write("<br>","Cars :", cars, "<br>")
cars.pop();
document.write("Remove Last Car Company :", cars, "</br>")
cars.shift();
document.write("Remove First Car Company :", cars, "</br>")
cars.unshift('BMW');
document.write("Add BMW at First Car Company :", cars, "</br>")
delete cars[1];
document.write("Remove Car Company from Position 1 :", cars, "</br>")
cars[1] = 'Audi';
document.write("Add Car Company at Position 1 :", cars, "</br>")
cars.splice(1,0, 'Ferrari', 'Lexus', 'Skoda')
document.write("Add Car Companies from possition 1 :", cars, "</br>")
cars.splice(0,3);
document.write("Remove Car Company from Position 0 to 2 :", cars, "</br>")