West Midlands | 26 March SDC | Iswat Bello | Sprint 2 | jq exercises#410
West Midlands | 26 March SDC | Iswat Bello | Sprint 2 | jq exercises#410Iswanna wants to merge 5 commits into
Conversation
- script-01.sh: Output the person's name without quotes. - script-02.sh: Output the person's address as a single comma-separated line without quotes.
- script-03.sh: Output the person's name and profession in the required format. - script-04.sh: Output each player's name on a separate line as required.
…es.json - script-05.sh: Output each player's name and city on one line. - script-06.sh: Output each player's name and their first score. - script-07.sh: Output each player's name and their last score.
- script-08.sh: Output each player's name and number of games played. - script-09.sh: Output each player's name and total score. - script-10.sh: Output the sum of all players' first scores. - script-11.sh: Output the sum of all scores from all games and players.
nedssoft
left a comment
There was a problem hiding this comment.
Good job in completing the exercises. The comment I left are good to haves as the requirements are already met.
|
|
||
| jq -r '.[] | "\(.name) \(.city)"' ./scores.json No newline at end of file |
There was a problem hiding this comment.
Can you think of another way to achieve the same without the slashes and brackets to improve readability?
There was a problem hiding this comment.
Yes, one simpler option is jq -r '.[] | .name + " " + .city' ./scores.json
| jq -r '.[] | "\(.name) \(.scores[0])"' scores.json | ||
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Yes, one simpler option is jq -r .[] | .name + " " + (.scores[0] | tostring)' scores.json
|
|
||
| jq -r '.[] | "\(.name) \(.scores[-1])"' scores.json |
There was a problem hiding this comment.
Yes, one simpler option is jq -r '.[] | .name + " " + (.scores[-1] | tostring)' scores.json
|
Thank you, @nedssoft, for the code review. |
- script-05.sh: Replace string interpolation with + operator for name and city - script-06.sh: Use string concatenation and tostring for name and first score - script-07.sh: Use string concatenation and tostring for name and last score - All scripts maintain the same output format
|
Closing PR because the SDC run has finished. Feel free to re-open if you're still working on it. |
Learners, PR Template
Self checklist
Changelist
This pull request adds a series of Bash scripts that use
jqto extract and process data from person.json and scores.json. Each script addresses a specific requirement, such as extracting names, formatting addresses, listing player stats, and calculating score totals.Questions
Hi, could you please review my PR? I would really appreciate your feedback.