### 3 persons

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}
```

### different fields

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
b.fathername = "Nikolai";
c.sex = "male";

```
### fields check

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
b.fathername = "Nikolai";
c.sex = "male";

if("age" in a){
	alert(a.age);
}
if("fathername" in b){
	alert(b.fathername);
}
if("sex" in c){
	alert(c.sex);
}
```

### array of persons

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
b.fathername = "Nikolai";
c.sex = "male";

var persons = [a,b,c,
	{
		name: "pasha",
		surname: "efimenko",
		age: 22
	}
]
```

### loop of persons

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
b.fathername = "Nikolai";
c.sex = "male";

var persons = [a,b,c,
	{
		name: "pasha",
		surname: "efimenko",
		age: 22
	}
]

for (var i = 0; i < persons.length; i++) {
	console.log(persons[i]);
}
```

### loop of fields loop of persons

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
b.fathername = "Nikolai";
c.sex = "male";

var persons = [a,b,c,
	{
		name: "pasha",
		surname: "efimenko",
		age: 22
	}
]

for (var i = 0; i < persons.length; i++) {
	var j = 0;
	for (var key in persons[i]) {
		j++;
		if(j < 3){
		console.log(key + ": " + persons[i][key]);
		}
	}
	console.log("\n");
}
```

### loop of loop of keys

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
b.fathername = "Nikolai";
c.sex = "male";

var persons = [a,b,c,
	{
		name: "pasha",
		surname: "efimenko",
		age: 22
	}
]

for (var i = 0; i < persons.length; i++) {
	var key = Object.keys(persons[i]);
	for (var c = 0; c < key.length; c++) {
		if(c < 2)
		console.log(key[c] + ": " + persons[i][key[c]]);
	}
	console.log("\n");
}
```

### loop of loop with optional fields

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
b.fathername = "Nikolai";
c.sex = "male";

var persons = [a,b,c,
	{
		name: "pasha",
		surname: "efimenko",
		age: 22
	}
]

var add = "";
for (var i = 0; i < persons.length; i++) {
	var key = Object.keys(persons[i]);
	for (var c = 0; c < key.length; c++) {
		if(c < 2)
		console.log(key[c] + ": " + persons[i][key[c]]);
		if(c >= 2)
		add += "\n" + key[c] + ": " + persons[i][key[c]];	
	}
	console.log("\n");
}
console.log("Дополнительные поля:" + add);	
```

### fullName

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
a.petr = "Ivanovich";
b.fathername = "Nikolai";
b.petr = "Nikolayovich";
c.sex = "male";
c.petr = "Alexandrovich";

var persons = [a,b,c,
	{
		name: "pasha",
		surname: "efimenko",
		age: 22,
		petr: "Alexandrovich"
	}
]

for (var i = 0; i < persons.length; i++) {
	persons[i].fullName =persons[i].surname + " " + persons[i].name + " " + persons[i].petr;
}
```

### serialize and deserialize

```javascript
var a = {
    name: "Ivan",
    surname: "Ivanov",
}
var b = {
    name: "Petr",
    surname: "Petrov",
}
var c = {
    name: "Alex",
    surname: "Sidarov",
}

a.age = 20;
a.petr = "Ivanovich";
b.fathername = "Nikolai";
b.petr = "Nikolayovich";
c.sex = "male";
c.petr = "Alexandrovich";

var persons = [a,b,c,
	{
		name: "pasha",
		surname: "efimenko",
		age: 22,
		petr: "Alexandrovich"
	}
]

var json = JSON.stringify(persons);

var k = JSON.parse(json);
k[4] = k[3];
var j = JSON.stringify(k);
```

### HTML

#### http://homework.pavelefimen95.fe.a-level.com.ua/js04/html-files

### HTML optional fields

#### http://homework.pavelefimen95.fe.a-level.com.ua/js04/HTMLOptionalFields-files

### HTML tr color

#### http://homework.pavelefimen95.fe.a-level.com.ua/js04/HTMLTrColor-files

### HTML th optional

#### http://homework.pavelefimen95.fe.a-level.com.ua/js04/jQHTMLThOptional-files

### jQ HTML th optional

#### http://homework.pavelefimen95.fe.a-level.com.ua/js04/jQHTMLThOptional-files

### jQ HTML th optional inputs 

#### http://homework.pavelefimen95.fe.a-level.com.ua/js04/jQHTMLThOptionalInputs-files

### Задание на синий пояс.

#### http://homework.pavelefimen95.fe.a-level.com.ua/js04/BlueBelt-files

### Задание на черный пояс

```javascript
var histor = ["1","2","1","2"];
var predictArray = {};
var predictValue;
while(true){
	predictValue = predictArray[histor[0] + histor[1] + histor[2] + histor[3]];
if(predictValue)
	console.log(predictValue);
else{
	console.log(Math.ceil(Math.random() * 2) + "rand");
}

var newValue = prompt("Введите 1 или 2");
if(!newValue)
	break;
predictArray[histor[0] + histor[1] + histor[2] + histor[3]] = newValue;  
histor.push(newValue);
histor.shift();
}
```


