/* let a = {
    name: 'Nikki',
    surname: 'Tikki',
    sex: 'male'
}
let b = {
    name: 'Nik',
    surname: 'Tikki',
    fathername: 'Anonovich'
}
let c = {
    name: 'Petro',
    surname: 'Tikki',
    age: 10
} */
/* debugger; */
//first attemps to find key)))
/* let arrayofKeys = ['sex','fathername', 'age'];
for(let key in a){
    for(let i=0; i<arrayofKeys.length; i++){
    if(key == arrayofKeys[i]){
        alert(key)
    }
        }
} */
//how to find key in object, maybe variant with entries better than that
/* function findFieldsinObject (obj,fieldForSearch){
    for(let key in obj){
        if(key == fieldForSearch){
            alert(`Object contains this field ${key}`);
        }
    }
}
 */
/* findFieldsinObject(a,'sex'); */

/* let persons = [a,b,c]; */
/* console.log(persons); */
//show all persons like obj
/* for(let i=0; i<persons.length; i++){
    console.log(persons[i]);
}
//show name and surname of persons
for(let i=0; i<persons.length; i++){
    console.log(persons[i].name + ' ' + persons[i].surname);
} */
/* debugger */;
//show all keys and values of all objects
/* for (let i = 0; i<persons.length; i++){
    for(let [key,value]of Object.entries(persons[i])){
            
        console.log(`${key}  ${value}`)
    }
} */


//attemps to push all keys from all object to one arr
/* for (let i = 0; i<persons.length; i++){

    let keysarr = [];
    for(let [key,value]of Object.entries(persons[i])){
            
        console.log(`${key}  ${value}`)
        keysarr.push(key);  
    }
    console.log(keysarr);
}
 */
/* let arrOfKeys = [];
        arrOfKeys.push(key);
        console.log(arrOfKeys); */
   

//add fathername
/* function addFieldInObject(obj){
    obj["fathername"] = prompt("input fathername", "");
    if(obj["fathername"] == null){
        obj["fathername"] = "";
    }
    alert("fathername add");
}

addFieldInObject(a);
addFieldInObject(b);
addFieldInObject(c);
//transform to json
let jsonPersons = JSON.stringify(persons);
console.log(jsonPersons); */

/* var str = "<table border='1'>"
for (let i=0;i<persons.length;i++){
    str += `<tr><td>${i}</td><td>${persons[i].name}</td> <td>${persons[i].surname}</td><td>${persons[i].fathername}</td><td>${persons[i].age}</td><td>${persons[i].sex}</td></tr>`
}
str += "</table>"

document.write(str) */





 //destructuring

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

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

let arr1 = [1,"abc"];

let [number,[s1='',s2='',s3='']] = arr1;


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

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

let arr2 = [1,2,3,4,5,6,7,10];
const {length} = arr2;
const [a,b,...numarr] = arr2;

 */