Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Write a method that takes an array of hashes with two keys each: country or state, and capital. Keys may be symbols or strings
  2.  
  3. The method should return an array of sentences declaring the state or country and its capital.
  4.  
  5. Examples
  6.  
  7. state_capitals = [{state: 'Maine', capital: 'Augusta'}]
  8. capital(state_capitals)[0] # returns "The capital of Maine is Augusta"
  9.  
  10. country_capitals = [{'country' : 'Spain', 'capital' : 'Madrid'}]
  11. capital(country_capitals)[0] # returns "The capital of Spain is Madrid"
  12.  
  13. mixed_capitals: [{"state" : 'Maine', capital: 'Augusta'}, {country: 'Spain', "capital" : "Madrid"}]
  14. capital(mixed_capitals)[1] # returns "The capital of Spain is Madrid"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement