Browse Source

not finish

Анатолий Пивоварский 1 year ago
parent
commit
f8b6ff7335
3 changed files with 95 additions and 0 deletions
  1. 15 0
      HW 3/js/script.js
  2. 13 0
      HW 4/index.html
  3. 67 0
      HW 4/js/script.js

+ 15 - 0
HW 3/js/script.js

@@ -132,3 +132,18 @@ for(i=0;i<10;i++){
 }console.log(str)
 
 //chess
+let str2 = ''
+for(n = 0;n<5;n++){
+str2 += '\n'
+for(y = 0;y < 12;y++){
+    if(y % 2 === 1){
+str2 += '#'} 
+    else {
+str2 += '.'}}
+str2 += '\n'
+for(y = 0;y < 12;y++){
+    if(y % 2 === 1){
+str2 += '.'} 
+    else {
+str2 += '#'}}}
+console.log(str2)

+ 13 - 0
HW 4/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<script src="./js/script.js"></script>
+<body>
+    
+</body>
+</html>

+ 67 - 0
HW 4/js/script.js

@@ -0,0 +1,67 @@
+//3 persons
+//different fields
+//fields check
+let a = {
+    name : "Johnny",
+    surname : "Depp",
+}
+a.age = 59;
+
+let b = {
+    name : "Brad",
+    surname : "Pitt",
+}
+b.fathername = "William";
+
+let c = {
+    name : "Leonardo",
+    surname : "Dicaprio",
+}
+
+c.sex = "man";
+
+if ("age" in a) {
+    alert("age in a")
+}
+if ("fathername" in b) {
+    alert("fathername in b")
+}
+if ("sex" in c){
+    alert("sex in c")
+}
+
+//array of persons
+
+a = {
+    name : "Johnny",
+    surname : "Depp",
+};
+b = {
+    name : "Brad",
+    surname : "Pitt",
+};
+c = {
+    name : "Leonardo",
+    surname : "Dicaprio",
+};
+
+let persons = [a, b, c];
+let d = {
+    name : "Vasya",
+    surname : "Pupkin",
+};
+persons.push(d)
+
+//loop of persons
+
+for(let i in persons){
+    console.log(persons[i])
+};
+
+//loop of name and surname
+for(let i in persons){
+    console.log(persons[i].name, 
+                persons[i].surname)
+};
+
+//loop of loop of values