Skip to content

Instantly share code, notes, and snippets.

@mikedao
Created June 29, 2016 15:47
Show Gist options
  • Save mikedao/7681e949e2163fedbee8f479d3b014d4 to your computer and use it in GitHub Desktop.
Save mikedao/7681e949e2163fedbee8f479d3b014d4 to your computer and use it in GitHub Desktop.

Solo

Given the array

["Harry Potter", "Hermione Granger", "Ron Weasley", "Luna Lovegood"]

Use #each to do the following:

  1. Print out each name.
  2. Print out each name in lower case.
  3. Print out each name in all uppercase.
  4. Print out only the first name.
  5. Print out only the last name.
  6. Print out the length of each name.
  7. Print out the last name and then the first name.

In pairs

Given the array

["Harry Potter", "Hermione Granger", "Ron Weasley", "Luna Lovegood"]

Use #each to do the following:

  1. Create a new array with the names all in lower case.
  2. Create a string consisting of the names all in upper case.
  3. Create a new array with only the first names.
  4. Create a new string consisting of only the last names.

Given the array

[1,20,3,40,5,123,435]

Use #each to do the following:

  1. Create an array of all the even numbers.
  2. Create an array of all the numbers greater than 15.
  3. Get the sum of all the numbers.
  4. Multiply all of the numbers together.

In Groups

Given the Array

[1,20,3,40,5,123,435]

Use #each to do the following:

  1. Return the first even number.
  2. Return an array of all th even numbers.
  3. Return all numbers that are bigger than three digits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment