Deliverables

Organize a Zoo

In this exercise, you’ll put on your zookeeper hat. While working at the zoo, you were delivered a large crate. Upon opening the crate, you discover it filled with cats, dogs, and of course, snakes. Here are the contents of the crate:

  var box = ["🐈","🐕", "🐍", "🐕", "🐈", "🐕", "🐍", "🐕", "🐕", "🐕", "🐈", "🐍", "🐈", "🐍", "🐍", "🐈"]

This, as they say, is not good. Your job is to organize each of these animals and put them in their own crate.

Here is what you’ll need to do:

  • Define three arrays. Each array should correspond to one type of animal.
  • Loops through all the animals in the box.
  • Place each animal in their appropriate box.
  • Print out each array to ensure that your animals are properly organized.

It should look like the following:

  ["🐍", "🐍", "🐍", "🐍", "🐍"]
  ["🐈", "🐈", "🐈", "🐈", "🐈"]
  ["🐕", "🐕", "🐕", "🐕", "🐕", "🐕"]
See forum comments
Download course materials from Github
Previous: Quiz: Control Flow in Action Next: Answer Key