Browse Source

Загрузить файлы ''

Viktor_ 1 year ago
parent
commit
d5aba70219
1 changed files with 227 additions and 246 deletions
  1. 227 246
      index.js

+ 227 - 246
index.js

@@ -1,246 +1,227 @@
-//html tree
-
-let body = {
-    tagName: "body",
-    subTags: [
-        {
-            tagName: "div",
-            subTags: [
-                { tagName: 'span', text: 'Enter a data please:' },
-                { tagName: 'br' },
-                { tagName: 'input', attr: { type: 'text', id: 'name'  } },
-                { tagName: 'input', attr: { type: 'text', id: 'surname' } },
-        
-            ]
-        },
-        {
-            tagName: 'div',
-            subTags: [
-                { tagName: 'button', text: 'ok', attr: { id:'ok' }  },
-                { tagName: 'button', text: 'Cancel', attr: { id: 'cancel' } }
-            ]
-        }
-
-        
-    ]
- 
-}
-
-body.subTags[1].subTags[1].text
-body.subTags[0].subTags[3].attr.id
-
-
-//declarative fields
-
-
-var notebook = {
-    brand: prompt('Enter brand'),
-    type:  prompt('Enter type'),
-    model: prompt('Enter model'),
-    ram: prompt('Enter ram'),
-    size: prompt('Enter size'),
-    weight: prompt('Enter weight'),
-    resolution: {
-        width: prompt('Enter width'),
-        height: prompt('Enter height'),
-    },
-};
-
-var phone = {
-    brand: prompt('What is brand?'),
-    model: prompt('What is model?'),
-    ram: +prompt('Enter you ram?'),
-    color: prompt('What is color?'),
-};
-
-//object links
-
-var person = {
-    name: prompt('What is you name?'),
-    surname: prompt("What is you surname?"),
-    married: confirm('Are you married?'),
-    smartphone: {
-        owner: person
-    },
-    laptop: {
-        owner: person
-    }
-}
-
-//imperative array fill 3
-
-let th = []
-th[1] = prompt();
-th[2] = prompt();
-th[0] = prompt()
-
-//while confirm
-
-let qw = "";
-while (qw !== true) {
-    qw = confirm('?')
-}
-
-//array fill
-let mass = [];
-let qu = ""
-while ( qu !== null) {
-    qu = prompt('Чего д0бавить?')
-    mass.push(qu)
-}
-
-//array fill nopush
-let mass1 = [], i=0 ;
-let qu1 = ""
-while ( qu1 != null) {
-    qu1 = prompt('Чего д0бавить?')
-    mass1[i++] = qu1
-    
-}
-
-//infinite probability
-
-let numb = 0
-while ( Math.random() < 0.9) {
-    numb += 1
-   
-}
-alert(numb)
-
-//empty loop
-
-let a = ''
-while (a != prompt());
-
-
-//progression sum
-let aa = 0
-for (i = 1; i < 100; i += 3){
-    aa = aa + i
-}
-
-//chess one line
-let q = ""
-for (i = 0; i < 15; i++){
-    if (i % 2 === 1) {
-        q = q + " "
-    } else {
-        q = q + "#"
-    }
-    
-}  
-
-//numbers
-
-/*let w = ""
-for (let i = 0; i < 10; i++){
-    w = w + "0123456789\n"
-  
-}
-console.log(w) */
-
-/*let r = ""
-for (let i = 0; i < 10; i++){
-    r = r + "\n" 
-    for (let q = 0; q < 1; q++) {
-        r = r + 0
-        for (let w = 0; w < 1; w++) {
-            r = r + 1
-            for (let e = 0; e < 1; e++) {
-                r = r + 2
-                for (let e = 0; e < 1; e++) {
-                    r = r + 3 
-                        for (let e = 0; e < 1; e++) {
-                            r = r + 4
-                            {
-                                for (let e = 0; e < 1; e++) {
-                                    r = r + 5 
-                                    {
-                                        for (let e = 0; e < 1; e++) {
-                                            r = r + 6
-                                            {
-                                                for (let e = 0; e < 1; e++) {
-                                                    r = r + 7
-                                                    {
-                                                        for (let e = 0; e < 1; e++) {
-                                                            r = r + 8 
-                                                            {
-                                                                for (let e = 0; e < 1; e++) {
-                                                                r = r + 9
-                                                        }
-                                                            }
-                                                        }
-                                                
-                                                    }
-             }       }           }       }   }
-                            }
-                
-                        }
-                
-                    }
-                
-            }
-        }
-    }
-}
-console.log(r)
-
-*/
-str = ""
-for (let i = 0; i < 10; i++){
-    str = str + '\n'
-    for (let j = 0; j < 10; j++){
-        str = str + j
-    }
-}
-console.log(str)
-
-
-//chess (не понял как слелать через 2 цикла чтобы была либо точка либо решетка и добавил +1 цикл в главный)
-
-let chess = ""
-for (let i = 0; i < 5; i++){
-    
-    chess += '\n'
-       
-    for (let j = 0; j < 12; j++){
-        if ( j % 2 === 1 ) {
-            chess += "."
-        } else {
-            chess += "#"
-        }
-        
-        
-    }
-
-    chess += '\n'
-    for (let j = 0; j < 12; j++){
-        if ( j % 2 === 1 ) {
-            chess += "#"
-        } else {
-            chess += "."
-        }
-        
-        
-    }
-
-
-} 
-alert(chess)
-
-// cubes
-
-let mass11 = []  
-for (let i = 0; i < 15; i++){
-
-    mass11.push(i ** 3)
-    
-}
-console.log(mass11[i])
-
-//multiply table
-
-
-
-
-
+//html tree
+
+let body = {
+    tagName: "body",
+    subTags: [
+        {
+            tagName: "div",
+            subTags: [
+                { tagName: 'span', text: 'Enter a data please:' },
+                { tagName: 'br' },
+                { tagName: 'input', attr: { type: 'text', id: 'name'  } },
+                { tagName: 'input', attr: { type: 'text', id: 'surname' } },
+        
+            ]
+        },
+        {
+            tagName: 'div',
+            subTags: [
+                { tagName: 'button', text: 'ok', attr: { id:'ok' }  },
+                { tagName: 'button', text: 'Cancel', attr: { id: 'cancel' } }
+            ]
+        }
+
+        
+    ]
+ 
+}
+
+body.subTags[1].subTags[1].text
+body.subTags[0].subTags[3].attr.id
+
+
+//declarative fields
+
+
+var notebook = {
+    brand: prompt('Enter brand'),
+    type:  prompt('Enter type'),
+    model: prompt('Enter model'),
+    ram: prompt('Enter ram'),
+    size: prompt('Enter size'),
+    weight: prompt('Enter weight'),
+    resolution: {
+        width: prompt('Enter width'),
+        height: prompt('Enter height'),
+    },
+};
+
+var phone = {
+    brand: prompt('What is brand?'),
+    model: prompt('What is model?'),
+    ram: +prompt('Enter you ram?'),
+    color: prompt('What is color?'),
+    
+};
+
+//object links
+
+var person = {
+    name: prompt('What is you name?'),
+    surname: prompt("What is you surname?"),
+    married: confirm('Are you married?'),
+   
+}
+person.phone = phone
+person.notebook = notebook
+phone.owner = person
+notebook.owner = person
+
+//imperative array fill 3
+
+let th = []
+th[1] = prompt();
+th[2] = prompt();
+th[0] = prompt()
+
+//while confirm
+
+let qw = "";
+while (qw !== true) {
+    qw = confirm('?')
+}
+
+//array fill
+let mass = [];
+let qu = ""
+while ( (qu = prompt('Чего д0бавить?')) !== null) {
+    
+    mass.push(qu)
+}
+
+
+
+//array fill nopush
+let mass1 = [], i=0 ;
+let qu1 = ""
+while ( (qu1 = prompt('Чего д0бавить?')) != null) {
+    
+    mass1[i++] = qu1
+    
+}
+
+//infinite probability
+
+let numb = 0
+while ( Math.random() < 0.9) {
+    numb += 1
+   
+}
+alert(numb)
+
+//empty loop
+
+let a = ''
+while (a != prompt());
+
+
+//progression sum
+let aa = 0
+for (i = 1; i < 100; i += 3){
+    aa = aa + i
+}
+
+//chess one line
+let q = ""
+for (i = 0; i < 15; i++){
+    if (i % 2 === 1) {
+        q = q + " "
+    } else {
+        q = q + "#"
+    }
+    
+}  
+
+//numbers
+
+/*let w = ""
+for (let i = 0; i < 10; i++){
+    w = w + "0123456789\n"
+  
+}
+console.log(w) */
+
+str = ""
+for (let i = 0; i < 10; i++){
+    str = str + '\n'
+    for (let j = 0; j < 10; j++){
+        str = str + j
+    }
+}
+console.log(str)
+
+
+//chess 
+
+let chess = ""
+for (let i = 0; i < 6; i++) {
+    
+    chess += '\n'
+       
+    for (let j = 0; j < 6; j++) {
+        if (i % 2 === 1) {
+            chess += ".#"
+        } else {
+            chess += "#."
+        }
+        
+        
+    }
+}
+alert(chess)
+
+// cubes
+
+let mass11 = []  
+for (let i = 0; i < 15; i++){
+
+    mass11.push(i ** 3)
+    
+}
+console.log(mass11[i])
+
+//multiply table
+
+
+let mas = []
+
+for (let i = 0; i < 10; i++){
+        mas[i] = []
+    for (let j = 0; j < 10; j++){
+        mas[i][j] = [j*i] ;     //<============  или   ============>      mas[i].push(i*j)
+    }
+}
+
+//matrix to html table    тут страшные и непонятные вещи происходили , короче , как-то склепал
+
+document.write( "<table border='1'>")
+let mas = []
+for (let i = 1; i < 10; i++){
+    mas[i] = []
+    document.write("<tr>")
+    for (let j = 1; j < 10; j++){
+    
+    document.write(  `<td>${mas[i][j] = [j * i]}</td> `)
+        
+    }
+    document.write("</tr>")
+}
+ document.write("</table>")
+
+
+
+//Задание на синий пояс: Треугольник   
+
+
+ let n = 6;
+ for (let i = 1; i <= n; i++) {
+     let str = '';
+     for (j = 1; j <= 2 * n - 1; j++) {
+         if (j >= n - (i - 1) && j <= n + (i - 1)) {
+             str += '#';
+         } else {
+             str += '.';
+         }
+     }
+     console.log(str);
+ }