GennadyBerg il y a 2 ans
Parent
commit
4f06f1ca9c

+ 11 - 0
js/06/hw06_03.html

@@ -0,0 +1,11 @@
+<header>
+    <h1>Item access</h1>
+</header>
+
+<body>
+    <script>
+        const arr5 = [prompt("Enter element"), prompt("Enter element"), prompt("Enter element"), prompt("Enter element"), ,];
+        alert(arr5[+prompt("Enter index value")]);
+    </script>
+
+</body>

+ 13 - 0
js/06/hw06_04.html

@@ -0,0 +1,13 @@
+<header>
+    <h1>Item change</h1>
+</header>
+
+<body>
+    <script>
+        const arr = [prompt("Enter element"), prompt("Enter element"), prompt("Enter element"), prompt("Enter element"), ,];
+        let a = +prompt("Enter index value");
+        arr[a] = a;
+        alert(arr).toUpperkeys;
+    </script>
+
+</body>

+ 0 - 9
js/06/hw06_05.html

@@ -20,15 +20,6 @@
             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>

+ 17 - 2
js/06/hw06_06.html

@@ -1,7 +1,22 @@
+<header>
+    <h1>Multiply table slice</h1>
+</header>
+
 <body>
     <script>
-        let a = prompt("Enter a phrase").split(' ').indexOf(prompt("Enter word"));
-        alert(a < 0 ? "Not found" : a);
+        arr = [];
+        for (let i = 1; i <= 5; i++) {
+            arr[i] = [];
+            for (let j = 1; j <= 5; j++) {
+                arr[i][j] = i * j;
+            }
+        }
+        arr = arr.slice(1)
+        for (let i = 0; i < 5; i++) {
+            arr[i] = arr[i].slice(1);
+        }
+        alert(arr);
+
     </script>
 
 </body>

+ 6 - 15
js/06/hw06_07.html

@@ -1,19 +1,10 @@
+<header>
+    <h1>IndexOf Word</h1>
+</header>
+
 <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);
-
-
-
+        let a = prompt("Enter a phrase").split(' ').indexOf(prompt("Enter word"));
+        alert(a < 0 ? "Not found" : a);
     </script>
-
 </body>

+ 23 - 0
js/06/hw06_08.html

@@ -0,0 +1,23 @@
+<header>
+    <h1>Reverse</h1>
+</header>
+
+<body>
+    <script>
+        const arr = [];
+        arr.push(prompt("Enter element 1"));
+        arr.push(prompt("Enter element2"));
+        arr.push(prompt("Enter element 3"));
+        arr.push(prompt("Enter element 4"));
+        arr.push(prompt("Enter element 5"));
+        alert(arr);
+        const arr2 = [];
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        alert(arr2);
+    </script>
+
+</body>

+ 31 - 0
js/06/hw06_09.html

@@ -0,0 +1,31 @@
+<header>
+    <h1>Reverse 2</h1>
+</header>
+
+<body>
+    <script>
+        const arr = [];
+        arr.push(prompt("Enter element 1"));
+        arr.push(prompt("Enter element2"));
+        arr.push(prompt("Enter element 3"));
+        arr.push(prompt("Enter element 4"));
+        arr.push(prompt("Enter element 5"));
+        alert(arr);
+        const arr2 = [];
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        arr2.push(arr.pop());
+        alert(arr2);
+        alert(arr);
+        arr.unshift(arr2.shift());
+        arr.unshift(arr2.shift());
+        arr.unshift(arr2.shift());
+        arr.unshift(arr2.shift());
+        arr.unshift(arr2.shift());
+        alert(arr);
+        alert(arr2);
+    </script>
+
+</body>

+ 20 - 0
js/06/hw06_10.html

@@ -0,0 +1,20 @@
+<header>
+    <h1>Copy</h1>
+</header>
+
+<body>
+    <script>
+        arr = [];
+        for (let i = 0; i < 5; i++) {
+            arr[i] = [];
+            for (let j = 0; j < 5; j++) {
+                arr[i][j] = (i + 1) * (j + 1);
+            }
+        }
+
+        alert(arr);
+        const deep = [...arr];
+        alert(deep);
+    </script>
+
+</body>

+ 22 - 0
js/06/hw06_11.html

@@ -0,0 +1,22 @@
+<header>
+    <h1>Deep Copy</h1>
+</header>
+
+<body>
+    <script>
+        arr = [];
+        for (let i = 0; i < 5; i++) {
+            arr[i] = [];
+            for (let j = 0; j < 5; j++) {
+                arr[i][j] = (i + 1) * (j + 1);
+            }
+        }
+        alert(arr);
+        const deep = [];
+        for (let i = 0; i < 5; i++) {
+            deep[i] = [...arr[i]];
+        }
+        alert(deep);
+    </script>
+
+</body>

+ 14 - 0
js/06/hw06_12.html

@@ -0,0 +1,14 @@
+<header>
+    <h1>Arrey Equals</h1>
+</header>
+
+<body>
+    <script>
+        const arr = [1, 2, 3, 4, 5];
+        let a = arr;
+        const arr2 = arr;
+        let b = arr2;
+        alert(a===b);
+    </script>
+
+</body>

+ 17 - 0
js/06/hw06_13.html

@@ -0,0 +1,17 @@
+<header>
+    <h1>Flat</h1>
+</header>
+
+<body>
+    <script>
+        arr = [];
+        for (let i = 0; i < 5; i++) {
+            arr[i] = [];
+            for (let j = 0; j < 5; j++) {
+                arr[i][j] = (i + 1) * (j + 1);
+            }
+        }
+        const arrCopy = [...arr[0], ...arr[1], ...arr[2], ...arr[3], ...arr[4]];
+        alert(arrCopy);
+    </script>
+</body>

+ 11 - 0
js/06/hw06_14.html

@@ -0,0 +1,11 @@
+<header>
+    <h1>Destruct</h1>
+</header>
+
+<body>
+    <script>
+        const str = prompt("Enter string_lenth min 9");
+        let [a1, a2, a3, a4, a5, a6, a7, a8, a9] = str;
+        alert(a1 + " " + a5 + " " + a9);
+    </script>
+</body>

+ 11 - 0
js/06/hw06_15.html

@@ -0,0 +1,11 @@
+<header>
+    <h1>Destruct Default</h1>
+</header>
+
+<body>
+    <script>
+        const str = prompt("Enter string");
+        let [a, b = '!', , d = '!', e = '!'] = str;
+        alert(b + " " + d + " " + e);
+    </script>
+</body>

+ 24 - 0
js/06/hw06_16.html

@@ -0,0 +1,24 @@
+<header>
+    <h1>Multiply table rest</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;
+            }
+        }
+        const [, ...a] = arr;
+        const [, ...aa0] = a[0];
+        const [, ...aa1] = a[1];
+        const [, ...aa2] = a[2];
+        const [, ...aa3] = a[3];
+        const [, ...aa4] = a[4];
+        arr = [aa0, aa1, aa2, aa3, aa4];
+        alert(arr);
+    </script>
+
+</body>

+ 13 - 0
js/06/hw06_17.html

@@ -0,0 +1,13 @@
+<header>
+    <h1>For alert</h1>
+</header>
+
+<body>
+    <script>
+        const names = ["John", "Paul", "George", "Ringo"];
+        for (let name of names) {
+            alert(`Hello, ${name}`);
+        }
+    </script>
+
+</body>

+ 17 - 0
js/06/hw06_18.html

@@ -0,0 +1,17 @@
+<header>
+    <h1>For Select Option</h1>
+</header>
+
+<body>
+    <script>
+        const currencies = ["USD", "EUR", "GBP", "UAH"];
+        let str = "<select>";
+        for (let currency of currencies) {
+            //    YOUR MAGIC HERE
+            str += `<option>${currency}</option>`;
+        }
+        str += "</select>";
+        document.write(str);
+    </script>
+
+</body>

+ 55 - 0
js/06/hw06_19.html

@@ -0,0 +1,55 @@
+<header>
+    <h1>For Table Horizontal</h1>
+</header>
+
+<body>
+    <style>
+        td {
+            padding: 5px;
+        }
+
+        td,
+        th {
+            border: 1px solid #999;
+            border-top-color: rgb(153, 153, 153);
+            border-top-style: solid;
+            border-top-width: 1px;
+            border-right-color: rgb(153, 153, 153);
+            border-right-style: solid;
+            border-right-width: 1px;
+            border-bottom-color: rgb(153, 153, 153);
+            border-bottom-style: solid;
+            border-bottom-width: 1px;
+            border-left-color: rgb(153, 153, 153);
+            border-left-style: solid;
+            border-left-width: 1px;
+            border-image-source: initial;
+            border-image-slice: initial;
+            border-image-width: initial;
+            border-image-outset: initial;
+            border-image-repeat: initial;
+        }
+
+        td {
+            display: table-cell;
+            vertical-align: inherit;
+        }
+
+        table {
+            border-collapse: collapse;
+            text-indent: initial;
+            border-spacing: 2px;
+        }
+    </style>
+    <script>
+        const names = ["John", "Paul", "George", "Ringo"];
+        let str = "<table><tbody><tr>";
+        for (let name of names) {
+            //    YOUR MAGIC HERE
+            str += `<td><section>${name}</section></td>`;
+        }
+        str += "</tr></tbody></table>";
+        document.write(str);
+    </script>
+
+</body>

+ 55 - 0
js/06/hw06_20.html

@@ -0,0 +1,55 @@
+<header>
+    <h1>For Table Vertical</h1>
+</header>
+
+<body>
+    <style>
+        td {
+            padding: 5px;
+        }
+
+        td,
+        th {
+            border: 1px solid #999;
+            border-top-color: rgb(153, 153, 153);
+            border-top-style: solid;
+            border-top-width: 1px;
+            border-right-color: rgb(153, 153, 153);
+            border-right-style: solid;
+            border-right-width: 1px;
+            border-bottom-color: rgb(153, 153, 153);
+            border-bottom-style: solid;
+            border-bottom-width: 1px;
+            border-left-color: rgb(153, 153, 153);
+            border-left-style: solid;
+            border-left-width: 1px;
+            border-image-source: initial;
+            border-image-slice: initial;
+            border-image-width: initial;
+            border-image-outset: initial;
+            border-image-repeat: initial;
+        }
+
+        td {
+            display: table-cell;
+            vertical-align: inherit;
+        }
+
+        table {
+            border-collapse: collapse;
+            text-indent: initial;
+            border-spacing: 2px;
+        }
+    </style>
+    <script>
+        const names = ["John", "Paul", "George", "Ringo"];
+        let str = "<table>";
+        for (let name of names) {
+            //    YOUR MAGIC HERE
+            str += `<tr><td>${name}</td></tr>`;
+        }
+        str += "</table>";
+        document.write(str);
+    </script>
+
+</body>

+ 62 - 0
js/06/hw06_21.html

@@ -0,0 +1,62 @@
+<header>
+    <h1>For Table Letters</h1>
+</header>
+
+<body>
+    <style>
+        td {
+            padding: 5px;
+        }
+
+        td,
+        th {
+            border: 1px solid #999;
+            border-top-color: rgb(153, 153, 153);
+            border-top-style: solid;
+            border-top-width: 1px;
+            border-right-color: rgb(153, 153, 153);
+            border-right-style: solid;
+            border-right-width: 1px;
+            border-bottom-color: rgb(153, 153, 153);
+            border-bottom-style: solid;
+            border-bottom-width: 1px;
+            border-left-color: rgb(153, 153, 153);
+            border-left-style: solid;
+            border-left-width: 1px;
+            border-image-source: initial;
+            border-image-slice: initial;
+            border-image-width: initial;
+            border-image-outset: initial;
+            border-image-repeat: initial;
+        }
+
+        td {
+            display: table-cell;
+            vertical-align: inherit;
+        }
+
+        table {
+            border-collapse: collapse;
+            text-indent: initial;
+            border-spacing: 2px;
+        }
+    </style>
+    <script>
+        const currencies = ["USD", "EUR", "GBP", "UAH"];
+        let str = "<table><thead><tr><th></th><th></th><th></th></tr></thead>";
+        for (let currency of currencies) { //цикл создает строки
+            //одна итерация цикла создает ОДНУ СТРОКУ
+            str += "<tr>";
+
+            for (let letter of currency) { //цикл создает ЯЧЕЙКИ в ОДНОЙ СТРОКЕ
+                //одна итерация цикла создает ОДНУ ЯЧЕЙКУ
+                str += `<td>${letter}</td>`;
+            }
+            str += "</tr>";
+
+        }
+        str += "</table>";
+        document.write(str);
+    </script>
+
+</body>

+ 71 - 0
js/06/hw06_22.html

@@ -0,0 +1,71 @@
+<header>
+    <h1>Multiply table</h1>
+</header>
+
+<body>
+    <style>
+        td {
+            padding: 5px;
+        }
+
+        td,
+        th {
+            border: 1px solid #999;
+            border-top-color: rgb(153, 153, 153);
+            border-top-style: solid;
+            border-top-width: 1px;
+            border-right-color: rgb(153, 153, 153);
+            border-right-style: solid;
+            border-right-width: 1px;
+            border-bottom-color: rgb(153, 153, 153);
+            border-bottom-style: solid;
+            border-bottom-width: 1px;
+            border-left-color: rgb(153, 153, 153);
+            border-left-style: solid;
+            border-left-width: 1px;
+            border-image-source: initial;
+            border-image-slice: initial;
+            border-image-width: initial;
+            border-image-outset: initial;
+            border-image-repeat: initial;
+        }
+
+        td {
+            display: table-cell;
+            vertical-align: inherit;
+        }
+
+        table {
+            border-collapse: collapse;
+            text-indent: initial;
+            border-spacing: 2px;
+        }
+    </style>
+
+    <script>
+        arr = [];
+        for (let i = 0; i < 5; i++) {
+            arr[i] = [];
+            for (let j = 0; j < 5; j++) {
+                arr[i][j] = (i + 1) * (j + 1);
+            }
+        }
+        let str = "<table><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead>";
+        for (let arrEl of arr) { //цикл создает строки
+            //одна итерация цикла создает ОДНУ СТРОКУ
+            str += "<tr>";
+
+            for (let val of arrEl) { //цикл создает ЯЧЕЙКИ в ОДНОЙ СТРОКЕ
+                //одна итерация цикла создает ОДНУ ЯЧЕЙКУ
+                str += `<td>${val}</td>`;
+            }
+            str += "</tr>";
+
+        }
+        str += "</table>";
+        document.write(str);
+
+
+    </script>
+
+</body>

+ 15 - 0
js/06/hw06_23.html

@@ -0,0 +1,15 @@
+<header>
+    <h1>Function Capitalize</h1>
+</header>
+
+<body>
+    <script>
+        const capitalize = str => {
+            str = str.toLowerCase();
+            let result = str[0].toUpperCase() + str.slice(1);
+            return result;
+        }
+        alert(capitalize("cANBerRa"));
+    </script>
+
+</body>

+ 16 - 0
js/06/hw06_24.html

@@ -0,0 +1,16 @@
+<header>
+    <h1>Map Capitalize</h1>
+</header>
+
+<body>
+    <script>
+        const capitalize = str => {
+            str = str.toLowerCase();
+            let result = str[0].toUpperCase() + str.slice(1);
+            return result;
+        }
+        let phrase = prompt("Enter a phrase").trim().split(' ').map(w => capitalize(w)).join(' ');
+        alert(phrase);
+    </script>
+
+</body>

+ 15 - 0
js/06/hw06_25.html

@@ -0,0 +1,15 @@
+<header>
+    <h1>Filter Lexics</h1>
+</header>
+
+<body>
+    <script>
+        const lexis = str => {
+            const lexx = ["xyz", "qwe"];
+            return !lexx.includes(str);
+        }
+        let phrase = prompt("Enter a phrase").trim().split(' ').filter(w => lexis(w)).join(' ');
+        alert(phrase);
+    </script>
+
+</body>

+ 13 - 0
js/06/hw06_26.html

@@ -0,0 +1,13 @@
+<header>
+    <h1>Beep Lexics</h1>
+</header>
+
+<body>
+    <script>
+        const lexx = ["xyz", "qwe"];
+        let phrase = prompt("Enter a phrase").trim().split(' ')
+            .map(w => lexx.includes(w) ? "BEEP" : w).join(' ');
+        alert(phrase);
+    </script>
+
+</body>

+ 16 - 0
js/06/hw06_27.html

@@ -0,0 +1,16 @@
+<header>
+    <h1>Reduce HTML</h1>
+</header>
+
+<body>
+    <script>
+        const currencies = ["", "USD", "EUR", "GBP", "UAH"];
+        let str = "<select>";
+        options = currencies.reduce((optionsStr, currency) => optionsStr  += `<option>${currency}</option>`);
+        str += options;
+        str += "</select>";
+        document.write(str);
+
+    </script>
+
+</body>

+ 30 - 0
js/06/hw06_28.html

@@ -0,0 +1,30 @@
+<header>
+    <h1>For Brackets Hell Check</h1>
+</header>
+
+<body>
+    <script>
+        const line = prompt();
+        const bracketsStack = [];
+        const openBrackets = ["[", "(", "{"];
+        const closeBrackets = ["]", ")", "}"];
+
+        let i = 0;
+        for (let character of line) {
+            //не обращайте внимания на символы, кроме трех видов скобок 
+            if (openBrackets.includes(character))
+                bracketsStack.push(character);
+            else {
+                idx = closeBrackets.indexOf(character);
+                if (idx >= 0) {
+                    if (bracketsStack.length == 0 || bracketsStack.pop() != openBrackets[idx]) {
+                        alert("Wrong brackets consistency in position: " + i)
+                        break; //оператор break прерывает цикл преждевременно
+                    }
+                }
+            }
+            i++;
+        }
+    </script>
+
+</body>