There are many times where you need to perform actions inside of large strings. Examples might be:Performing a loop Implementing conditionals
I want to render this on a website, however the food attribute is optional, so I can't expect that it will always be available. So if I run code like this:
This will work and show the object properties:
But if I remove the optional 'food' attribute, the output will be:
Now if you update the page you'll see that the Food line item has disappeared, and if you add the food attribute back into the object it will show up again.