Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Programming Quiz - Navigating the Food Chain (3-8)
- *
- * Use a series of ternary operator to set the category to one of the following:
- * - "herbivore" if an animal eats plants
- * - "carnivore" if an animal eats animals
- * - "omnivore" if an animal eats plants and animals
- * - undefined if an animal doesn't eat plants or animals
- *
- * Notes
- * - use the variables `eatsPlants` and `eatsAnimals` in your ternary expressions
- * - `if` statements aren't allowed ;-)
- */
- // change the values of `eatsPlants` and `eatsAnimals` to test your code
- var eatsPlants = true;
- var eatsAnimals = false;
- var category = (eatsPlants && eatsAnimals) ? "omnivore" : ( eatsPlants ? "herbivore": ( eatsAnimals ? "carnivore" : undefined ) );
- console.log(category);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement