this is one way to code it, Ruby provides a simpler syntax to do the same thing - take a look at the answers for a simpler way.