File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,3 +5,5 @@ set -euo pipefail
55# The input for this script is the scores.json file.
66# TODO: Write a command to output the names of each player, as well as their city.
77# Your output should contain 6 lines, each with two words on it.
8+
9+ jq -r ' .[] | [.name, .city] | join(" ")' ./scores.json
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ set -euo pipefail
66# TODO: Write a command to output just the names of each player along with the score from their first attempt.
77# Your output should contain 6 lines, each with one word and one number on it.
88# The first line should be "Ahmed 1" with no quotes.
9+ jq -r ' .[] | [.name, .scores[0]] | join(" ")' ./scores.json
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ set -euo pipefail
66# TODO: Write a command to output just the names of each player along with the score from their last attempt.
77# Your output should contain 6 lines, each with one word and one number on it.
88# The first line should be "Ahmed 4" with no quotes.
9+ jq -r ' .[] | [.name, .scores[-1]] | join(" ")' ./scores.json
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ set -euo pipefail
66# TODO: Write a command to output just the names of each player along with the number of times they've played the game.
77# Your output should contain 6 lines, each with one word and one number on it.
88# The first line should be "Ahmed 3" with no quotes.
9+ jq -r ' .[] | [.name, (.scores | length)] | join(" ")' ./scores.json
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ set -euo pipefail
66# TODO: Write a command to output just the names of each player along with the total scores from all of their games added together.
77# Your output should contain 6 lines, each with one word and one number on it.
88# The first line should be "Ahmed 15" with no quotes.
9+ jq -r ' .[] | [.name, (.scores | add)] | join(" ")' ./scores.json
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ set -euo pipefail
55# The input for this script is the scores.json file.
66# TODO: Write a command to output the total of adding together all players' first scores.
77# Your output should be exactly the number 54.
8+ jq ' [.[].scores[0]] | flatten | add' ./scores.json
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ set -euo pipefail
55# The input for this script is the scores.json file.
66# TODO: Write a command to output the total of adding together all scores from all games from all players.
77# Your output should be exactly the number 164.
8+ jq ' [.[].scores] | flatten | add' ./scores.json
You can’t perform that action at this time.
0 commit comments