Conversation
Ride ShareWhat We're Looking For
Good job overall! In general you code is functional and well-written. However, it often feels like you're trying to cram too many things onto one line of code. This can be tempting, but remember that one of the main functions of a piece of code is to be read by other humans. Lines in a file are cheap but developer time is expensive, so making your code a little more verbose to increase readability is definitely worthwhile. Other than that things look good - keep up the hard work! |
| # - the average rating for each driver | ||
| drivers.each do |driver, records| | ||
| avg_rating_driver = ((records.sum { |x| x[:RATING] }).to_f / records.length).round(2) | ||
| puts "Driver #{driver} has an average rating of #{avg_rating_driver}" |
There was a problem hiding this comment.
There's a lot going on on line 69. I might break this up across multiple lines, possibly using an intermediate variable.
| # - Which driver made the most money? | ||
| dd = drivers.map do |driver, records| | ||
| {name: driver, totalcost: records.sum { |x| x[:COST] }} | ||
| end |
There was a problem hiding this comment.
dd is not a great variable name - as a newcomer to this code, I have no idea what that contains. You should use something more descriptive, such as income_by_driver.
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?