Created
December 30, 2019 17:19
-
-
Save LukeSkyRunner/28805802147805fdf680473ed9d18ecd to your computer and use it in GitHub Desktop.
Javascript Swtich Fruit Practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TO SEE HOW THIS EXAMPLE WORKS, UN COMMENT OUT THE FOLLOWING LINE | |
//const fruit = prompt ("Enter the fruit name:"); | |
let type = ""; | |
switch (fruit){ | |
case "pear" || "apple": | |
type = "pome" | |
break; | |
case "peach" || "coconut": | |
type = "drupe" | |
break; | |
case "strawberry" || "blackberry": | |
type = "berry" | |
break; | |
case "beans" || "peas": | |
type = "legumes" | |
break; | |
default: | |
type = "other" | |
break; | |
} | |
console.log(`${fruit} is type of: ${type}.`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment