Question: I have been introduced to the concept of ternary operators, and it's pretty straightforward to understand the notation:

`desired_variable = true ? false ? "value1" : "value2";`

I could not understand, however, the rational behind adding a second variable, even if I understand the answer. To use a classic example:

```
var eatsPlants = false;
var eatsAnimals = false;
var category;

category = eatsPlants ? eatsAnimals ? "omnivore" : "herbivore" : eatsAnimals ? "carnivore" : undefined;
console.log(category)

```

Here, one observation: If I change the order of the variables to the statement below, the function does not work:

```
category = eatsAnimals ? eatsPlants? "carnivore" : undefined : eatsPlants ? "herbivore" : "omnivore";
console.log(category)

```

My question: why doesn't the function work when the terms are inverted? And how do I choose the order of the terms when I have two or more variables (and therefore four or more results)?

Answer: 
Ternary expressions have 3 expressions inside of them. However, because ternary expressions are themselves expressions you can put ternary expressions inside other ternary expressions. The ternary expressions in your example above look so confusing because they are multiple nested ternary expressions. This confusion can be better cleared up with formatting and use of parentheses:

```js
var eatsPlants = false;
var eatsAnimals = false;
var category = null;

category =
  (eatsPlants ?
    (eatsAnimals ? "omnivore" : "herbivore")
    :
    (eatsAnimals ? "carnivore" : undefined)
  );
console.log(category);
```
You cannot change the order between `then` and `else` parts, as that affects the outcome (if you don't also negate the condition). You can however change the nesting, and write either

```
category = eatsPlants
  ? eatsAnimals
      ? "omnivore"
      : "herbivore"
  : eatsAnimals
      ? "carnivore"
      : undefined;

```

or

```
category = eatsAnimals
  ? eatsPlants
      ? "omnivore"
      : "carnivore"
  : eatsPlants
      ? "herbivore"
      : undefined;

```