Step: String interpolation: \(expr)

String interpolation: \(expr)

Inside a string, \(expr) splices a jq value into the text — cleaner than a chain of +.

"\(.city), \(.country)"

Why it matters: interpolation coerces numbers to strings for you; .firstName + .age would error because you can't + a string and a number.

Your turn: produce "Charles is 41" using interpolation.

Input:
{
  "firstName": "Charles",
  "lastName": "Doe",
  "age": 41,
  "location": {
    "city": "San Francisco",
    "postal-code": "94103"
  },
  "hobbies": [
    "chess",
    "netflix"
  ],
  "pets": [
    {
      "name": "Bear",
      "kind": "dog"
    },
    {
      "name": "Jerry",
      "kind": "cat"
    }
  ]
}
Expected:
"Charles is 41"
Step 15 of 27