Skip to content

Instantly share code, notes, and snippets.

@albertcoder
Last active February 10, 2018 23:26
Show Gist options
  • Save albertcoder/d292f4f69a769a350401fc9624f64bea to your computer and use it in GitHub Desktop.
Save albertcoder/d292f4f69a769a350401fc9624f64bea to your computer and use it in GitHub Desktop.
What size to wear?
/*
* Programming Quiz: What do I Wear? (3-7)
*/
// change the values of `shirtWidth`, `shirtLength`, and `shirtSleeve` to test your code
var shirtWidth = 26;
var shirtLength = 33;
var shirtSleeve = 9.63;
if ((18 <= shirtWidth < 20) && (28 <= shirtLength < 29) && (8.13 <= shirtSleeve < 8.38)) {
console.log("S");
}
else if ((20 <= shirtWidth < 22) && (29 <= shirtLength < 30) && (8.38 <= shirtSleeve < 8.63)) {
console.log("M");
}
else if ((22 <= shirtWidth < 24) && (30 <= shirtLength < 31) && (8.63 <= shirtSleeve < 8.88)) {
console.log("L");
}
else if ((24 <= shirtWidth < 26) && (31 <= shirtLength < 33) && (8.88 <= shirtSleeve < 9.63)) {
console.log("XL");
}
else if ((26 <= shirtWidth < 28) && (33 <= shirtLength < 34) && (9.63 <= shirtSleeve < 10.13)) {
console.log("2XL");
}
else if ((30 === shirtWidth) && (34 === shirtLength) && (10.13 === shirtSleeve)) {
console.log("3XL");
}
else {console.log("N/A");}
/*
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("N/A");
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment