Browse Source

HW<10>done

Gennadysht 2 năm trước cách đây
mục cha
commit
7e37f7995a

+ 13 - 0
js/10/hw10_01_while confirm.html

@@ -0,0 +1,13 @@
+<head> while confirm</head>
+
+<body>
+    <script>
+        let i = 0
+        while (!confirm('Похоже что ВАм уже достаточно?')) {
+            alert('Еще итерация')
+            i++
+        }
+        alert(`Вам надоело за ${i} раз.`)
+
+    </script>
+</body>

+ 12 - 0
js/10/hw10_02_array fill.html

@@ -0,0 +1,12 @@
+<head>array fill</head>
+
+<body>
+    <script>
+        let arr = [];
+        while (a = prompt('Введите очередной элемент массива')) {
+            arr.push(a);
+            alert(arr);
+        }
+        alert('введенный массив имеет длину:' + arr.length);
+    </script>
+</body>

+ 14 - 0
js/10/hw10_03_ array fill nopush.html

@@ -0,0 +1,14 @@
+<head>array fill</head>
+
+<body>
+    <script>
+        let arr = [];
+        let i = 0;
+        while (a = prompt('Введите очередной элемент массива')) {
+            arr[i] = (a);
+            alert(arr);
+            i++
+        }
+        alert('введенный массив имеет длину:' + arr.length);
+    </script>
+</body>

+ 17 - 0
js/10/hw10_04_infinite probability.html

@@ -0,0 +1,17 @@
+<head>array fill</head>
+
+<body>
+    <script>
+        let i = 0
+        let a = 0.5;
+        while ((a - 0.9) <= 0) {
+            a = Math.random();
+            i++;
+            if ((a - 0.9) > 0) {
+                break;
+                //alert(i);
+            }
+        }
+        alert(i);
+    </script>
+</body>

+ 15 - 0
js/10/hw10_05_empty loop.html

@@ -0,0 +1,15 @@
+<head>array fill</head>
+
+<body>
+    <script>
+        let i = 0
+        let a = 1
+        while (a != false) {
+            a = prompt("не вводите ничего");
+            alert(i);
+            i++;
+        }
+        alert(`Вам надоело за ${i} раз.`)
+
+    </script>
+</body>

+ 16 - 0
js/10/hw10_06_progression sum.html

@@ -0,0 +1,16 @@
+<head>array fill</head>
+
+<body>
+    <script>
+        let i = 0;
+        const arr = [];
+        let x = 1;
+        let n = +prompt("введите кол-во членов прогрессии N");
+        for (; i < n; i++) {
+            x = x + 3;
+            arr.push(x);
+        }
+        result = ((2 * 1) + 3 * (n - 1)) / 2 * n;
+        alert(result);
+    </script>
+</body>

+ 19 - 0
js/10/hw10_07_ chess one line.html

@@ -0,0 +1,19 @@
+<head>array fill</head>
+
+<body>
+    <script>
+        let a = 0;
+        let b = (confirm("ODD or Even"));
+        if (b) {
+            let a = +prompt("enter ODD number elements");
+        }
+        else
+            let a = +prompt("enter even number elements");
+
+        let str = "";
+        for (let i = 0; i < a; i++) {
+            str += " #";
+        }
+        console.log(str);
+    </script>
+</body>

+ 14 - 0
js/10/hw10_08_numbers.html

@@ -0,0 +1,14 @@
+<head>numbers</head>
+
+<body>
+    <script>
+        let str = "";
+        for (let i = 0; i < 10; i++) {
+            for (let j = 0; j < 10; j++) {
+                str += j;
+            }
+            str += '\n';
+        }
+        alert(str);
+    </script>
+</body>

+ 17 - 0
js/10/hw10_09_chess.html

@@ -0,0 +1,17 @@
+<head>chess</head>
+
+<body>
+    <script>
+        let lineSize = +prompt("Enter size of table line ");
+        let str = "";
+        for (let i = 0; i < lineSize; i++) {
+            for (let j = 0; j < lineSize; j++) {
+                str += ((j+i)% 2) == 0 ? "." : "#";
+            }
+            str += '\n';
+        }
+        alert(str);
+
+
+    </script>
+</body>

+ 13 - 0
js/10/hw10_10_cubes.html

@@ -0,0 +1,13 @@
+<head>cubes</head><br><br>
+
+<body>
+    <script>
+        let n = +prompt("Enter N (Length)");
+        const arr = [];
+        for (let i = 0; i < n; i++) {
+            arr[i] = i ** 3;
+            //console.log(arr);
+        }
+        alert(arr);
+    </script>
+</body>

+ 14 - 0
js/10/hw10_11_multiply table.html

@@ -0,0 +1,14 @@
+<head>multiply table</head>
+
+<body>
+    <script>
+        arr = [];
+        for (let i = 1; i <= 9; i++) {
+            arr[i - 1] = [];
+            for (let j = 1; j <= 9; j++) {
+                arr[i - 1][j - 1] = i * j;
+            }
+        }
+        console.log(arr);
+    </script>
+</body>

+ 24 - 0
js/10/hw10_12_read array of objects.html

@@ -0,0 +1,24 @@
+<head>read array of objects</head>
+
+<body>
+    <script>
+
+        const readArrayOfObjects = () => {
+            const arr = [];
+            do {
+                let obj = null;
+                while ((key = prompt("Enter obj property name")) &&
+                    (val = prompt("Enter obj property value"))) {
+                    if (!obj)
+                        obj = {};
+                    obj[key] = val;
+                }
+                if (obj)
+                    arr.push(obj);
+            }
+            while (confirm("continue&&???..."))
+            return arr;
+        }
+        console.log(readArrayOfObjects());
+    </script>
+</body>

+ 22 - 0
js/10/hw10_131_rhomb new.html

@@ -0,0 +1,22 @@
+<head>rhomb</head><br>
+<br>
+
+<body>
+    <script>
+        let lineSize = +prompt("Enter Line size");
+        const printLine = (num, lineSize) => {
+            let leftOffset = (lineSize - num) / 2;
+            let str = '.'.repeat(leftOffset) + '#'.repeat(num) + '.'.repeat(leftOffset);
+            return str;
+
+        }
+        let a = "";
+        for (i = -lineSize+1; i <= lineSize; i += 2) {
+            a += "<a style='font-family : monospace,monospace;'>" + printLine(lineSize - Math.abs(i), lineSize) + "</a><br>";
+        }
+
+
+        document.write(a);
+
+    </script>
+</body>

+ 24 - 0
js/10/hw10_13_rhomb.html

@@ -0,0 +1,24 @@
+<head>rhomb</head><br>
+<br>
+
+<body>
+    <script>
+        let lineSize = +prompt("Enter Line size");
+        const printLine = (num, lineSize) => {
+            let leftOffset = (lineSize - num) / 2;
+            let str = '.'.repeat(leftOffset) + '#'.repeat(num) + '.'.repeat(leftOffset);
+            return str;
+
+        }
+        let a = "";
+        for (i = 1; i <= lineSize; i += 2) {
+            a += "<a style='font-family : monospace,monospace;'>" + printLine(i, lineSize) + "</a><br>";
+        }
+        for (i = lineSize-2; i > 0; i -= 2) {
+            a += "<a style='font-family : monospace,monospace;'>" + printLine(i, lineSize) + "</a><br>";
+        }
+
+        document.write(a);
+
+    </script>
+</body>

+ 18 - 0
js/10/hw10_14_DOM multiply table .html

@@ -0,0 +1,18 @@
+<head>DOM multiply table</head>
+
+<body>
+    <script>
+        let table = document.createElement("table");
+        for (let i = 1; i <= 9; i++) {
+            let row = document.createElement("tr");
+            table.append(row);
+            for (let j = 1; j <= 9; j++) {
+                let column = document.createElement("td");
+                column.innerText = i * j;
+                row.append(column);
+
+            }
+        }
+        document.body.append(table);
+    </script>
+</body>

+ 20 - 0
js/10/hw10_15_DOM highlight cell.html

@@ -0,0 +1,20 @@
+<head>DOM highlight cell</head>
+
+
+<body>
+    <script>
+        let table = document.createElement("table");
+        for (let i = 1; i <= 9; i++) {
+            let row = document.createElement("tr");
+            table.append(row);
+            for (let j = 1; j <= 9; j++) {
+                let column = document.createElement("td");
+                column.innerText = i * j;
+                row.append(column);
+                column.onmouseover = () => column.style.backgroundColor = "grey";
+                column.onmouseout = () => column.style.backgroundColor = "white";
+            }
+        }
+        document.body.append(table);
+    </script>
+</body>

+ 36 - 0
js/10/hw10_16_DOM highlight cross.html

@@ -0,0 +1,36 @@
+<head>DOM cross</head>
+
+
+<body>
+    <script>
+        let table = document.createElement("table");
+        for (let i = 1; i <= 9; i++) {
+            let row = document.createElement("tr");
+            table.append(row);
+            for (let j = 1; j <= 9; j++) {
+                let column = document.createElement("td");
+                column.innerText = i * j;
+                row.append(column);
+                column.onmouseover = () => {
+                    for (let k = 0; k < 9; k++) {
+                        table.rows[i - 1].cells[k].style.backgroundColor = "lightgrey";
+                    }
+                    for (let k = 0; k < 9; k++) {
+                        table.rows[k].cells[j - 1].style.backgroundColor = "lightgrey";
+                    }
+                    column.style.backgroundColor = "grey";
+                }
+                column.onmouseout = () => {
+                    for (let k = 0; k < 9; k++) {
+                        table.rows[i - 1].cells[k].style.backgroundColor = "white";
+                    }
+                    for (let k = 0; k < 9; k++) {
+                        table.rows[k].cells[j - 1].style.backgroundColor = "white";
+                    }
+                    column.style.backgroundColor = "white";
+                }
+            }
+        }
+        document.body.append(table);
+    </script>
+</body>

+ 0 - 0
js/11/hw11_01_.html


+ 0 - 0
js/11/hw11_02_.html


+ 0 - 0
js/11/hw11_03_.html


+ 0 - 0
js/11/hw11_04_.html


+ 0 - 0
js/11/hw11_05_.html


+ 0 - 0
js/11/hw11_06.html


+ 0 - 0
js/11/hw11_07_ .html


+ 0 - 0
js/11/hw11_08_ .html


+ 0 - 0
js/11/hw11_09_ .html


+ 0 - 0
js/11/hw11_10_ .html