-
Notifications
You must be signed in to change notification settings - Fork 54
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
Update worksheet.rb #48
base: master
Are you sure you want to change the base?
Conversation
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.
Nice work Sandy, you hit the learning goals here. Well done. I do think you should consider:
- Using Enumerable methods. They could help you dry things up a bit.
- Creating your own methods to break things down and for practice.
# Which layers are nested in each other? | ||
# Which layers of data "have" within it a different layer? | ||
# Which layers are "next" to each other? | ||
all_drivers = [ |
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.
👍 , your indentation is a bit odd however.
# all_drivers.each do |driver| | ||
# puts driver[:driver_id] + " has given" + " " + driver[:rides].length.to_s + " " + "rides." | ||
# 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.
👍 , however next time uncomment what's working so I can test it easily.
# all_drivers.each do |driver| | ||
# total_money_made = 0 | ||
# driver_id = driver[:driver_id] | ||
# # p driver | ||
# | ||
# driver[:rides].each do |num| | ||
# ride_cost = num[:cost] | ||
# total_money_made += ride_cost | ||
# end | ||
# puts "#{driver_id} earned a total of: $#{total_money_made}." | ||
# 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.
👍 , check your indentation here and I suggest using either the .sum_by
or .reduce
methods to calculate the totals.
# all_drivers.each do |driver| | ||
# driver_id = driver[:driver_id] | ||
# ride_count = driver[:rides].length | ||
# sum = 0 | ||
# | ||
# driver[:rides].each do |num| | ||
# ride_rating = num[:rating] | ||
# sum += ride_rating | ||
# end | ||
# puts "#{driver_id} has an average rating of #{sum/ride_count.to_f}." | ||
# 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.
👍 , again I suggest using sum or reduce here as well.
# total_money_made = 0 | ||
# driver_id = driver[:driver_id] | ||
# | ||
# driver[:rides].each do |num| | ||
# ride_cost = num[:cost] | ||
# total_money_made += ride_cost | ||
# end | ||
# if highest_earnings < total_money_made | ||
# highest_earnings = total_money_made | ||
# highest_earner_driver_id = driver_id | ||
# 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.
This is a great place to use the max
method
fixing tab size
Good feedback, thanks |
Assignment Submission: Ride Share
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
.map
? If so, when? If not, why, or when would be a good opportunity to use it?