Skip to content

Instantly share code, notes, and snippets.

@OmarYehiaDev
Forked from desinas/quizWhatDoIwear.js
Last active July 14, 2019 20:06
Show Gist options
  • Save OmarYehiaDev/68316df9d1eef09222fbedf79754f18e to your computer and use it in GitHub Desktop.
Save OmarYehiaDev/68316df9d1eef09222fbedf79754f18e to your computer and use it in GitHub Desktop.
What do I wear Quiz (3-7) of Udacity Front end developer
/*
* 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
*/
// change the values of `shirtWidth`, `shirtLength`, and `shirtSleeve` to test your code
var shirtWidth = 19;
var shirtLength = 28.5;
var shirtSleeve = 8.13;
// Write your if/else code here
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")
}
// Phew. I've just finished it!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment