A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript ๐ Don't miss our Quizzes!
Let's chat: @nairihar
Post #2212
4.95K
CHALLENGE
function getCity(person) {
return person?.address?.city ?? 'Unknown';
}
const data = [
null,
{ name: 'Alice' },
{ name: 'Bob', address: null },
{ name: 'Charlie', address: { street: '123 Main' } },
{ name: 'David', address: { city: 'Boston' } }
];
const cities = data.map(getCity);
console.log(cities);- ๐ 3
- โค 2





