let a = {
    name: 'Olga',
    surname: 'Kosareva'
}
let b = {
    name: 'Elena',
    surname: 'Krasnik'
}
let c = {
    name: 'Leonid',
    surname: 'Onoprienko'
}

a.age = 42;
b.fatherName = 'Igorevna'
c.sex = 'male'


let arrofPersons = [a, b, c, {name: 'Anatoly', surname: 'Petrenko', age: 30}]

for(let i = 0; i < arrofPersons.length; i++) {
    console.log(arrofPersons[i]);
}

for(let person of arrofPersons) {
    console.log(person.surname + ' ' + person.name);
}

for(let i = 0; i < arrofPersons.length; i++) {
   for (let key in arrofPersons[i]) {
        console.log(arrofPersons[i][key]);
    }
}

for(let obj of arrofPersons) {
    if(obj.name && obj.surname) {
        obj.fullName = obj.name + ' ' + obj.surname
    }
 }
console.log(arrofPersons);

JSON.stringify(arrofPersons);


// let str = "<table border='1'>"
// arrofPersons.map(person => {
//     str += `<tr><td>${person.name}</td><td>${person.surname}</td></tr>`
// })
// str += '</table>'
// document.write(str)


let str = "<table border='1'>"
arrofPersons.map(person => {
    str += `<tr>`
    Object.values(person).map(value => str += `<td>${value}</td>`)
    str += `</tr>`
})
str += '</table>'
document.write(str)

var someTree = {
    tagName: "table", //html tag
    subTags: [ //вложенные тэги
        {
                    tagName: "tr",
                    subTags: [
                        {
                            tagName: "td",
                            text: "some text",
                        },
                        {
                            tagName: "td",
                            text: "some text 2",
                        }
                    ]
        }
    ],
    attrs:
    {
        border: 1,
    },
}

let table = `<${someTree.tagName} ${Object.keys(someTree.attrs)[0]}=${Object.values(someTree.attrs)}>`

for(let subTag of someTree.subTags) {
    table += `<${subTag.tagName}>`
    for(let innerTag of subTag.subTags) {
        table += `<${innerTag.tagName}>${innerTag.text}</${innerTag.tagName}>`
    }
}
table += `</${someTree.tagName}>`
document.write(table);

let arr = [1,2,3,4,5, "a", "b", "c"]

let [odd1, even1, odd2, even2, odd3, ...letters] = arr

let arr2 = [1, "abc"]

let [number, [s1, s2, s3]] = arr2

let obj = {
    name: 'Ivan',
    surname: 'Petrov',
    children: [
        {name: 'Maria'},
        {name: 'Nikolay'}
    ]
}

let {
    children:
        [{name: name1}, {name: name2}]} = obj


let arr3 = [1,2,3,4, 5,6,7,10];

let [first, second, {length = arr3.length}] = arr3











