GennadyBerg пре 2 година
родитељ
комит
6719e5d5b5
5 измењених фајлова са 72 додато и 0 уклоњено
  1. 6 0
      js/06/hw06_01.html
  2. 6 0
      js/06/hw06_02.html
  3. 34 0
      js/06/hw06_05.html
  4. 7 0
      js/06/hw06_06.html
  5. 19 0
      js/06/hw06_07.html

+ 6 - 0
js/06/hw06_01.html

@@ -0,0 +1,6 @@
+<body>
+    <script>
+        const arr4 = [confirm("ВСе ли вам понятно с массивами?"), confirm("А теперь?..."), , , ,];
+        alert(console.log(arr4["length"]));
+    </script>
+</body>

+ 6 - 0
js/06/hw06_02.html

@@ -0,0 +1,6 @@
+<body>
+    <script>
+        const arr5 = [prompt("Enter element"), prompt("Enter element"), prompt("Enter element"), prompt("Enter element"), ,];
+        alert(arr5["length"]);
+    </script>
+</body>

+ 34 - 0
js/06/hw06_05.html

@@ -0,0 +1,34 @@
+<header>
+    <h1>Multiply table</h1>
+</header>
+
+<body>
+    <script>
+        arr = [];
+        for (let i = 1; i <= 5; i++) {
+            arr[i] = [];
+            for (let j = 1; j <= 5; j++) {
+                arr[i][j] = i * j;
+            }
+        }
+        let str = "";
+        for (let i = 1; i <= 5; i++) {
+            for (let j = 1; j <= 5; j++) {
+                val = arr[i][j];
+                str += ' ' + val.toString().padStart(2, ' ');
+            }
+            str += '\n'
+        }
+        alert(str);
+        //arr[+prompt("Enter index")];
+        //arr[+prompt("Enter index")]= prompt("Enter value");
+
+        arr = arr.slice(1)
+        for (let i = 0; i < 5; i++) {
+            arr[i] = arr[i].slice(1);
+        }
+        const arr6 = [...arr[0], ...arr[1], ...arr[2], ...arr[3], ...arr[4]];
+        alert(arr6);
+    </script>
+
+</body>

+ 7 - 0
js/06/hw06_06.html

@@ -0,0 +1,7 @@
+<body>
+    <script>
+        let a = prompt("Enter a phrase").split(' ').indexOf(prompt("Enter word"));
+        alert(a < 0 ? "Not found" : a);
+    </script>
+
+</body>

+ 19 - 0
js/06/hw06_07.html

@@ -0,0 +1,19 @@
+<body>
+    <script>
+        arr = [];
+        for (i = 0; i < 5; i++)
+            arr.push(prompt('Enter ' + (i + 1) + ' element'));
+        arr2 = [];
+        for (i = 0; i < 5; i++)
+            arr2.push(arr.pop());
+        alert(arr + "\n" + arr2);
+        //задание reverse
+        for (i = 0; i < 5; i++)
+            arr.unshift(arr2.shift());
+        alert(arr + "\n" + arr2);
+
+
+
+    </script>
+
+</body>