Skip to content

Instantly share code, notes, and snippets.

@vanderhoop
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save vanderhoop/d875bc66356ef36bfdb5 to your computer and use it in GitHub Desktop.

Select an option

Save vanderhoop/d875bc66356ef36bfdb5 to your computer and use it in GitHub Desktop.

Iterating with .each

Using the data provided, complete the steps outlined below.

students_array = ["Evan Berg", "Robert Silverblatt", "El Toro Roja", "Jared Norcott", "Jessica Franko", "Andy Fritz", "Aaron Gregory", "Dewey", "Janine Harper", "Erica Kantor", "Larkin", "Sarah McDonald", "Jenny Nguyen", "Ariel Olin", "Ryan Parks", "Grayson Reinhard", "Maria Schettino", "Will Schjang", "Neil Sidhu", "Yinan Song", "Ade Ugbogbo", "Jacqueline Williams", "Carrie Xu", "Anastasia Konecky"]
  1. Pull from upstream master.
  2. Create a each_practice.rb file in today's "Classwork" folder.
  3. Within your new file, write code that uses .each to print each of the students names to the console.
  4. Save and commit your work with a sensible commit message.
  5. Now use another .each to print "<student> is a student who is learning to learn." for each student in students_array.
  6. Save and commit your work with a sensible commit message.
  7. Use .each to iterate through the students array, printing "<student> is a part of JCrew" if and only if the student's first name starts with J.
  8. Save and commit your work with a sensible commit message.



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment