Let's assume that you have the following object:
javascriptlet erik = { age: 31 }
You can't use the optional chaining operator to create/modify a new variable:
javascript// ❌ Uncaught SyntaxError: Invalid left-hand side in assignment erik.location?.city = 'Barcelona'
But you can do the following:
javascripterik.location = erik.location || {} erik.location.city = 'Barcelona'
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.