Deviopath › TypeScript

Optional Chaining on Nested Data

Easy · Narrowing

A company may have no ceo, a CEO may have no address, and an address may have no city.

Write ceoCities(companies: Company[]): string[] that returns "<company name>: <city>" for every company, using "unknown" when the city is missing at any level. Use optional chaining (?.) with ??.

Next: Classify JSON with unknown