Conversation
Ride ShareWhat We're Looking For
Love the way you organized the data by driver, by ride! So sorry for the previous review! |
| end | ||
|
|
||
|
|
||
| prof_one = profit_per_driver(drive_history,:DR0001).sum |
There was a problem hiding this comment.
Considering this is called profit_per_driver, it'd be preferable that it found and returned the sum of the profit rather than an array that still needs to be summed.
| max = profit_array.max | ||
|
|
||
| puts " *** Max Profit:" | ||
| if max == prof_one |
There was a problem hiding this comment.
This is not critical but I wanted to mention: this is a good case where you could keep up with the driver name for each profit so that you could read the driver_id rather than creating a whole conditional chain like this.
One way to do that would be:
prof_one = { driver_id: :DR0001, profit: profit_per_driver(drive_history,:DR0001).sum }
...
max = profit_array.max_by | profit_hash |
profit_hash.profit
end
puts "The maximum was earned by driver #{max.driver_id} with a total profit of $#{max.profit}."The reason I want to call this out is because if we had 100 drivers, the code below would be unmanageable. Reach out to me if that doesn't make sense.
| averages_array = [average_one, average_two, average_three, average_four] | ||
| max_average = averages_array.max | ||
|
|
||
| puts " *** Highest Driver Rating: " |
There was a problem hiding this comment.
Same down here about keeping up with the driver name so that you don't need a whole conditional chain.
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?