script.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //3 person
  2. var a = new Object();
  3. a.name="";
  4. a.surname="";
  5. var b = new Object();
  6. b.name="";
  7. b.surname="";
  8. var c = new Object();
  9. c.name="";
  10. c.surname="";
  11. //different fileds
  12. a.patronymic="";
  13. a.collorHair='';
  14. a.sex='';
  15. b.collorSkin='';
  16. b.gender='';
  17. b.presenceOfChildren='';
  18. c.collorEyes='';
  19. c.nationality='';
  20. c.footSize='';
  21. //fileds check
  22. for ( let boobSyzze in a ) {
  23. if( boobSyzze != "name" || boobSyzze != "surname" || boobSyzze != "patronymic" || boobSyzze != "collorHair" || boobSyzze != "sex" );
  24. alert(boobSyzze);
  25. }
  26. for ( let boobSyzze in b ) {
  27. if( boobSyzze != "name" || boobSyzze != "surname" || boobSyzze != "collorSkin" || boobSyzze != "gender" || boobSyzze != "presenceOfChildren" );
  28. alert(boobSyzze);
  29. }
  30. for ( let boobSyzze in c ) {
  31. if( boobSyzze != "name" || boobSyzze != "surname" || boobSyzze != "collorEyes" || boobSyzze != "nationality" || boobSyzze != "footSize" );
  32. alert(boobSyzze);
  33. }
  34. //array of persons
  35. let persons =[{}, {}, {}];
  36. for (let key of persons){
  37. key.name = 'Mary';
  38. key.surname = 'Jain';
  39. key.familyDoctor = 'dr.Dre';
  40. }
  41. //loop of persons
  42. for (let key of persons) { console.log(key);}
  43. //loop of name and surname;
  44. for (let key in persons){
  45. console.log(persons[key].name);
  46. console.log(persons[key].surname);
  47. }
  48. // loop of loop of values;
  49. persons.forEach(function(keyOfPersone){
  50. for (let key in keyOfPersone){
  51. console.log(keyOfPersone[key]);
  52. }
  53. });
  54. //full name
  55. persons.forEach(function(fullN){
  56. let counter = 0;
  57. for (let key in fullN){
  58. if (key==='name')
  59. counter++;
  60. }
  61. if (counter >= 1) {
  62. fullN.fullname = "Mary Jain";
  63. }
  64. })
  65. //serialize
  66. let serialize = JSON.stringify(persons);
  67. console.log(serialize);
  68. //deserialize
  69. let deserialize = JSON.parse('{"name": "2pac", "surname": "shakur", "familyDoctor":"Orlando Anderson", "fullName":"Lesane Parish Crooks"}');
  70. persons.push(deserialize);
  71. //HTML
  72. var str = '<table border="1">';
  73. for (let i = 0; i < persons.length; i++){
  74. str += '<tr style="background-color:black; color:yellow;">';
  75. for (let key in persons[i]){
  76. str += `<td>${persons[i][key]}</td>`;
  77. }
  78. str += '</tr>';
  79. }
  80. str += '</table>';
  81. document.write(str);
  82. //th