Step: Collect into an array: [ ]

Collect into an array: [ ]

Wrapping a filter in [ ] gathers everything it streams back into a single array.

[ .pets[].name ]   # stream of names  ->  one array of names

Why it matters: [ ... ] is how you turn a stream back into a value you can return, sort, or count. It's the inverse of .[].

Your turn: collect all pet names into one array.

Input:
{
  "firstName": "Charles",
  "lastName": "Doe",
  "pets": [
    {
      "name": "Bear",
      "kind": "dog"
    },
    {
      "name": "Jerry",
      "kind": "cat"
    }
  ]
}
Expected:
[
  "Bear",
  "Jerry"
]
Step 11 of 27