I have the sample JS functionality below (simplified for example).
function getConsentStatus(cat, catSub, catSubCheck){
// case statement which checks
// some cookies and JS objects
//returns true/false
}
return getConsentStatus(event.cat, event.catSub, event.catSubCheck);
I want to delay the executing until either the "OptanonConsent" cookie exists or the "OnetrustActiveGroups" object exists. I don't need code on how to check the cookie/object. How is it possible to delay the value from being returned in the "getConsentStatus" function until the cookie/object exists? I'm assuming, I'd need this check to be the initial check in the function and only have the rest of the function execute until one of those two conditions exists? Any ideas or help welcomed! Thanks!