Can anyone help me with this Javascript coding quiz?

Hi I just begin learning JavaScript and had a problem with getting this coding quiz right. Can someone show me what’s the right way to do it? Thanks in advance!

/*

  • 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 :wink:
      */

// change the values of eatsPlants and eatsAnimals to test your code
var eatsPlants = false;
var eatsAnimals = true;

console.log(category);

Sometimes it helps to do a flow chart kinda thing of the question?



var a = false;
var b = true;

var check =
if a true
{     if b true
      {then a & b  }
      else
      { just a }  
}
else
if b true
  { then just b }
else
  undef
 
( substituting.... if?true then  ... for "?"  , and ...else: ... for " : " )
var check = a if?true then (b if?true then "a & b true" else: "just a true") else: (b if?true then"b true" else: undefined);

This should see you through

var eatsPlants = true;
var eatsAnimals = false;

var category = eatsPlants && eatsAnimals ? “omnivore”:
eatsPlants ? “herbivore” : eatsAnimals ? “carnivore” : undefined;

console.log(category);