ScriptS
Reactiflux4y ago
6 replies
Script

✅ – Script – 21-22 Nov 7

How do I check if boolean object key contains value?
Category is a string, so I just check if it contains any value and then I am able to update it
gig.category = req.body.category ? req.body.category : gig.category;


but approvedForMenu is a boolean. So my ternary operator is checking for true or false instead.
I can change the value to true but I cant change it back to false.
How do I write the code so I can be able to change it back to false?
gig.approvedForMenu = req.body.approvedForMenu ? req.body.approvedForMenu : gig.approvedForMenu;
Was this page helpful?