Open
Conversation
CheezItMan
reviewed
Sep 15, 2020
Collaborator
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work Li, you hit the learning goals here. Well done.
I do think this could be broken up into methods making the steps easier to read and understand.
| # into this data structure, such as "DR0004" | ||
| # and "3rd Feb 2016" and "RD0022" | ||
|
|
||
| rides = [{driver_id:"DR0001", date:["3rd Feb 2016", "3rd Feb 2016", "5th Feb 2016"], cost:[10, 30, 45], ride_id:["RD0003","RD0015","RD0003"], rating:[3, 4, 2]}, |
Collaborator
There was a problem hiding this comment.
👍 , this works, but you have basically 3 parallel arrays in the dates, costs, ride_id and ratings. You have to keep the indexes aligned.
This works for the given examples, but for more general-purpose problems this might work as well. Each entry is labeled and relatively easy identify what value goes with each item.
Suggested change
| rides = [{driver_id:"DR0001", date:["3rd Feb 2016", "3rd Feb 2016", "5th Feb 2016"], cost:[10, 30, 45], ride_id:["RD0003","RD0015","RD0003"], rating:[3, 4, 2]}, | |
| driver_data = { | |
| dr0001: [ | |
| { | |
| date: "3rd Feb 2016", | |
| cost: [10], | |
| ride_id: "RD0003", | |
| rating: 3, | |
| } | |
| ... | |
| ], | |
| dr0002: ... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?