// const array = []; // for (let i = 0; i < 10; i++) { // array.push(i); // } // for (let i = 1; i < array.length; i++) { // array[i] = array[i] + array[i - 1]; // } // console.log(array); // 3 persons // const a = { // name: "Anatoliy", // surname: "Stateham", // }; // const b = { // name: "Arnold", // surname: "Hudoba", // }; // const c = { // name: "Stepan", // surname: "Johnson", // }; // different fields // a.age = 16; // a.fathername = "Andreevich"; // a.sex = "male"; // b.age = 25; // b.fathername = "Bogdanovich"; // b.sex = "male"; // c.age = 18; // c.fathername = "Vasilevich"; // c.sex = "male"; // fields check // if ("age" in a) { // alert("Optional field 'age' found in object a"); // } // if ("fathername" in a) { // alert("Optional field 'fathername' found in object a"); // } // if ("sex" in a) { // alert("Optional field 'sex' found in object a"); // } // if ("age" in b) { // alert("Optional field 'age' found in object b"); // } // if ("fathername" in b) { // alert("Optional field 'fathername' found in object b"); // } // if ("sex" in b) { // alert("Optional field 'sex' found in object b"); // } // if ("age" in c) { // alert("Optional field 'age' found in object c"); // } // if ("fathername" in c) { // alert("Optional field 'fathername' found in object c"); // } // if ("sex" in c) { // alert("Optional field 'sex' found in object c"); // } // array of persons // const persons = []; // persons.push(a, b, c); // persons.push({ // name: "Semen", // surname: "Harrington", // age: 30, // fathername: "Sergeevich", // sex: "male", // }); // loop of persons // for (let person in persons) { // console.log(person); // } // loop of name and surname // for (let person in persons) { // console.log(person.name, person.surname); // } // loop of loop of values // let count = 0; // for (let person in persons) { // console.log(`--- ${++count} object ---`); // for (key in persons[person]) { // console.log(`${key}: ${persons[person][key]}`); // } // } // fullName // for (let person in persons) { // for (key in persons[person]) { // if (!persons[person]?.fathername) { // persons[ // person // ].fullName = `${persons[person].name} ${persons[person].surname}`; // } else { // persons[ // person // ].fullName = `${persons[person].name} ${persons[person].surname} ${persons[person].fathername}`; // } // } // } // console.log(persons); // serialize // const stringPersons = JSON.stringify(persons); // console.log(stringPersons); // deserialize // let personString = // '{"name":"Mariya","surname":"Gordon","age":26,"sex":"female","fullName":"Mariya Gordon"}'; // persons.push(JSON.parse(personString)); // console.log(persons); // HTML && HTML optional fields && HTML tr color && HTML th optional // let countHTML = 0; // for (let person in persons) { // let strObj = `
"; // strObj += key[0].toUpperCase() + key.slice(1); // strObj += " | "; // strObj += ""; // strObj += value; // strObj += " | "; // strObj += "