1234567891011121314151617181920212223242526 |
- <header>Check result</header>
- <body>
- <script>
- function checkResult(original, validator) {
- function wrapper(...params) {
- let result = null;
- while (validator(result = original(...params)) == false);
- return result;
- }
- return wrapper;
- }
-
- const numberPrompt = checkResult(prompt, x => !isNaN(+x))
- let number = +numberPrompt("Введите число", "0")
-
- const gamePrompt = checkResult(prompt, x => ['камень', 'ножницы', 'бумага'].includes(x.toLowerCase()))
- const turn = gamePrompt("Введите что то из списка: 'камень', 'ножницы', 'бумага'")
-
-
-
-
- </script>
- </body>
|