123456789101112131415161718 |
- <head>insorted</head>
- <body>
- <script>
- let inSorted = (...args) => {
- let prevVal = null;
- for (el of args) {
- if (prevVal != null && prevVal > el)
- return false;
- prevVal = el
- }
- return true;
- }
- console.log(inSorted(1, 2, 3, 6, 8));
- console.log(inSorted(1, 2, 3, 2, 8));
- </script>
- </body>
|