Skip to content

Instantly share code, notes, and snippets.

@Laner12
Forked from mikedao/each_exercises.md
Created March 24, 2016 00:05
Show Gist options
  • Save Laner12/f19e7f65952c0df9f83b to your computer and use it in GitHub Desktop.
Save Laner12/f19e7f65952c0df9f83b to your computer and use it in GitHub Desktop.

Exercises

  • If you had an array of numbers, e.g. [1,2,3,4], how do you print out the doubles of each number? Triples?
  • If you had the same array, how would you only print out the even numbers? What about the odd numbers?
  • How could you create a new array which contains each number multipled by 2?
  • Given an array of first and last names, e.g. ["Alice Smith", "Bob Evans", "Roy Rogers"], how would you print out the full names line by line?
  • How would you print out only the first name?
  • How would you print out only the last name?
  • How could you print out only the initials?
  • How can you print out the last name and how many characters are in it?
  • How can you create an integer which represents the total number of characters in all the names?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment