Conversation
Ride ShareWhat We're Looking For
Great job overall! I've left a couple of comments inline, but it's clear that the learning goals for this assignment around working with loops and complex data structures were met. Keep up the hard work! |
| drivers = [ | ||
| {id: "DR0004", trips: [ # driver | ||
| {date: "3rd Feb 2016", cost: 5, rider_id: "RD0022", rating: 5}, #trip | ||
| {date: "4th Feb 2016", cost: 10, rider_id: "RD0022", rating: 4}, # trip |
There was a problem hiding this comment.
While I like the idea of this data structure, I might space it out in the file a little differently. In general, best practice is that unless the entire array or hash is going on one line, each key/value pair should get its own line. So in this case:
drivers = [
{
id: "DR004",
trips: [
{date: "3rd Feb 2016", cost: 5, rider_id: "RD0022", rating: 5}, #trip
{date: "4th Feb 2016", cost: 10, rider_id: "RD0022", rating: 4}, # trip
]
}, {
... next driver
}
}| puts "\nCongratulations, #{highest_earning_driver}! You earned the most money." | ||
|
|
||
| # Which driver has the highest average rating? | ||
| highest_rated_driver = drivers.max_by { |driver| driver[:average_rating] }[:id] |
There was a problem hiding this comment.
I would probably break lines 51 and 55 out across multiple lines using do...end rather than curly braces. If you're worried about the subscript (the [:id]) at the end, you could stick that inside the string interpolation.
ride share
Congratulations! You're submitting your assignment.
Comprehension Questions
.map? If so, when? If not, why, or when would be a good opportunity to use it?