Hint
Look into how the promise is resolved and how the optional chaining and nullish coalescing operators are used to access nested properties
function getPokemon() {
return new Promise((resolve) => {
resolve({
name: 'Pikachu',
abilities: {
ability1: 'Static',
ability2: null
}
})
})
}
getPokemon().then((pokemon) => {
console.log(pokemon.name)
console.log(pokemon.abilities?.ability2 ?? 'Not found')
console.log(pokemon.abilities?.ability3 ?? 'Not found')
})Pikachu null Not found