-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sockets - Tatiana #31
base: master
Are you sure you want to change the base?
Conversation
Ride ShareWhat We're Looking For
Overall | You should use Git more! 2 commits is slim! |
all_averages = ride_share.map do |driver, rides| | ||
{ name: driver, average: rides.sum do |record| | ||
((record[:rating].to_f) / rides.length).round(2) | ||
end } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly easy to read, but be aware, the {
can be on it's own line or with the thing it's attached to. usually you'd see this formatted:
all_averages = ride_share.map do |driver, rides|{
name: driver, average: rides.sum do |record|
((record[:rating].to_f) / rides.length).round(2)
end
}end
{ name: driver, most_money_day: array.max_by do |record| | ||
record[:cost] | ||
end } | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation got a bit out of hand here.
ride share
Congratulations! You're submitting your assignment.
Comprehension Questions
.each
loops and then using the.sum
and.map
enumerables to return some quick calculations..map
for question 4 to return an array of hashes with name: driver and value: $ total earnings - since it is necessary to store that returned value in a variable in order to use it to later..map
? If so, when? If not, why, or when would be a good opportunity to use it?map
to create a smaller array of hashes that I could then use themax_by
to determine which driver made the most $ dough.sum
enumerable since it only required one step, it seemed more straight forward and thus felt easier.