hw12_04_check_01.html 459 B

12345678910111213141516171819
  1. <header>Check result</header>
  2. <body>
  3. <script>
  4. function checkResult(original, validator) {
  5. function wrapper(...params) {
  6. let result = null;
  7. while (validator(result = original(...params)) != true);
  8. return result;
  9. }
  10. return wrapper;
  11. }
  12. const randomHigh = checkResult(Math.random, (x) => x >= 0.5);
  13. alert(randomHigh());
  14. </script>
  15. </body>