I have this deeply nested value
eventsubcategoryvalue: data.body.spending.requestspend==='y' ? data.body.spending.allowspend : chargeamount
so here eventsubcategoryvalue is decided on basis of result of the ternary operator. I want to use optional chaining here instead of having this complex nested thing. How can I re write it? I am unable to understand even after going through the MDN doc.
How can one rewrite this with optional chaining?