-
Notifications
You must be signed in to change notification settings - Fork 0
/
What do I Wear? (3-7)
61 lines (55 loc) · 2.13 KB
/
What do I Wear? (3-7)
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
/*
* Programming Quiz: What do I Wear? (3-7)
*
* Using if/else statements, create a series of logical expressions that logs the size of a t-shirt based on the measurements of:
* - shirtWidth
* - shirtLength
* - shirtSleeve
*
* Use the chart above to print out one of the following correct values:
* - S, M, L, XL, 2XL, or 3XL
*/
/*
* QUIZ REQUIREMENTS
* 1. Your code should have the variables `shirtWidth`, `shirtLength`, and `shirtSleeve`
* 2. Your code should include an `if...else` conditional statement
* 3. Your code should use logical expressions
* 4. Your code should produce the expected output
* 6. Your code should not be empty
* 7. BE CAREFUL ABOUT THE EXACT CHARACTERS TO BE PRINTED.
*/
// change the values of w for `shirtWidth`, l for `shirtLength`, and s for `shirtSleeve` to test your code
var [shirtWidth, shirtLength, shirtSleeve] = [18, 29, 8.47];
/*
* To gain confidence, check your code for the following combination of [shirtWidth, shirtLength, shirtSleeve, expectedSize]:
* [18, 28, 8.13, 'S']
* [19.99, 28.99, 8.379, 'S']
* [20, 29, 8.38, 'M']
* [22, 30, 8.63, 'L']
* [24, 31, 8.88, 'XL']
* [26, 33, 9.63, '2XL']
* [27.99, 33.99, 10.129, '2XL']
* [28, 34, 10.13, '3XL']
* [18, 29, 8.47, 'NA']
*/
if(shirtWidth >= 18 && shirtWidth < 20 && shirtLength >= 28 && shirtLength < 29 && shirtSleeve >= 8.13 && shirtSleeve < 8.38) {
console.log('S');
}
else if(shirtWidth >= 20 && shirtWidth < 22 && shirtLength >= 29 && shirtLength < 30 && shirtSleeve >= 8.38 && shirtSleeve < 8.63) {
console.log('M');
}
else if(shirtWidth >= 22 && shirtWidth < 24 && shirtLength >= 30 && shirtLength < 31 && shirtSleeve >= 8.63 && shirtSleeve < 8.88) {
console.log('L');
}
else if(shirtWidth >= 24 && shirtWidth < 26 && shirtLength >= 31 && shirtLength < 33 && shirtSleeve >= 8.88 && shirtSleeve < 9.63) {
console.log('XL');
}
else if(shirtWidth >= 26 && shirtWidth < 28 && shirtLength >= 33 && shirtLength < 34 && shirtSleeve >= 9.63 && shirtSleeve < 10.13) {
console.log('2XL');
}
else if(shirtWidth >= 28 && shirtLength >= 34 && shirtSleeve >= 10.13 ) {
console.log('3XL');
}
else{
console.log('NA');
}