Create ride-share.rb - Leanne Rivera#31
Conversation
|
Small Note: You need to work on proper indentation. Feel free to use the keyboard shortcut we put into Atom |
|
|
||
| hash[:rides].each do |hash2| | ||
| driver_total << hash2[:cost] | ||
| driver_sum = driver_total.sum |
There was a problem hiding this comment.
You're running this sum method each time you add a cost to driver_total, to be more efficient only do the sum after you finish adding all the costs to driver_total. Otherwise you're duplicating effort.
You could also use sum_by instead of .each to do this totaling.
ride share
Congratulations! You're submitting your assignment.
Comprehension Questions
.map?