hw11_05_testinSorted.html 551 B

123456789101112131415161718192021222324
  1. <head>test inSorted</head>
  2. <body>
  3. <script>
  4. let inSorted = (...args) => {
  5. let prevVal = null;
  6. for (el of args) {
  7. if (prevVal != null && prevVal > el)
  8. return false;
  9. prevVal = el
  10. }
  11. return true;
  12. }
  13. let arr = [];
  14. while (a = prompt('Введите очередной элемент массива')) {
  15. arr.push(a);
  16. alert(arr);
  17. }
  18. console.log(inSorted(arr));
  19. </script>
  20. </body>