Endangered Species


jQuery JavaScript Selectors Public

Hard  

5min


An HTML div element contains lists of endangered species grouped by continent and the species population status.

<div>
    <ul data-continent="North America">
        <li data-species="California condor">Critically Endangered</li>
        <li data-species="American bison">Near Threatened</li>
    </ul>
    <ul data-continent="Europe">
        <li data-species="Cave bear">Extinct</li>
    </ul>
</div>

Write a function that returns how endangered a species is on a particular continent. For example endangeredSpecies('North America', 'American bison') would return 'Near Threatened'.

ECMAScript 5.1, jQuery v3.2.1 (available as $)
   

  •   Example case: Wrong answer
  •   Several species and continents: Wrong answer
  •   Continents with the same species: Wrong answer