-
Notifications
You must be signed in to change notification settings - Fork 0
/
Switch.js
41 lines (35 loc) · 928 Bytes
/
Switch.js
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
// use full in react
// switch (key) {
// case value:
// break;
// default:
// break;
// }
const month = "march"
switch (month) {
case "jan":
console.log("January");
break;
case "feb":
console.log("feb");
break;
case "march":
console.log("march");
break;
case "april":
console.log("april");
break;
default:
console.log("default case match");
break;
}
//! BMI with switch case.
const BMI = (weight / ((height * height) / 10)).toFixed(2);
results.innerHTML = `<span>${BMI}</span>`;
if (BMI < 18.6) {
weight_guide.innerHTML = `<span>Under Weight = Less than 18.6</span>`;
} else if (BMI >= 18.6 && BMI <= 24.9) {
weight_guide.innerHTML = `<span>Normal Range = 18.6 and 24.9</span>`;
} else if (BMI > 24.9) {
weight_guide.innerHTML = `<span>Overweight = Greater than 24.9</span>`;
}