-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditionals.js
93 lines (85 loc) · 2.31 KB
/
conditionals.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
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
/* eslint-disable*/
// var myAge = 50;
// if (myAge < 50) {
// console.log("Joven");
// } else {
// console.log("Viejo");
// }
function getColorStringFromCode(colorNumber) {
if (colorNumber == 0) //Numeric code for Red
{
return "Red";
}
else if (colorNumber == 1) //Numeric code for Green
{
return "Green";
}
else if (colorNumber == 2) //Numeric code for Blue
{
return "Blue";
}
else if (colorNumber == 3) //Numeric code for Pink
{
return "Pink";
}
else if (colorNumber == 4) //Numeric code for Brown
{
return "Brown";
}
else if (colorNumber == 5) //Numeric code for Black
{
return "Black";
}
else if (colorNumber == 6) //Numeric code for White
{
return "White";
}
else if (colorNumber == 7) //Numeric code for Gray
{
return "Gray";
}
else {
return undefined;
}
}
function getColorStringFromCode2(colorNumber) {
var colorName;
switch (colorNumber) {
case 0:
colorName = "Red";
break;
case 1:
colorName = "Green";
break;
case 2:
colorName = "Blue";
break;
case 3:
colorName = "Pink";
break;
case 4:
colorName = "Brown";
break;
case 5:
colorName = "Black";
break;
case 6:
colorName = "White";
break;
case 7:
colorName = "Gray";
break;
default:
colorName = undefined;
}
return colorName;
}
console.log(getColorStringFromCode(0) + " = " + getColorStringFromCode2(0));
console.log(getColorStringFromCode(1) + " = " + getColorStringFromCode2(1));
console.log(getColorStringFromCode(2) + " = " + getColorStringFromCode2(2));
console.log(getColorStringFromCode(3) + " = " + getColorStringFromCode2(3));
console.log(getColorStringFromCode(4) + " = " + getColorStringFromCode2(4));
console.log(getColorStringFromCode(5) + " = " + getColorStringFromCode2(5));
console.log(getColorStringFromCode(6) + " = " + getColorStringFromCode2(6));
console.log(getColorStringFromCode(7) + " = " + getColorStringFromCode2(7));
console.log(getColorStringFromCode(8) + " = " + getColorStringFromCode2(8));