<header>Check result</header> <body> <script> function checkResult(original, validator) { function wrapper(...params) { let result = null; while (validator(result = original(...params)) != true); return result; } return wrapper; } const alwaysSayYes = checkResult(confirm, x => x); alwaysSayYes(); </script> </body>