12_HTML_optional_fields.js 519 B

1234567891011121314151617181920212223242526272829303132
  1. let persons = [
  2. {
  3. name: 'Sergey',
  4. surname: 'Honcharenko',
  5. age: 28,
  6. isMarried: false,
  7. },
  8. {
  9. name: 'Andrew',
  10. surname: 'Klymchuk',
  11. middleName: 'Anatoliyovych',
  12. haveAJob: true,
  13. },
  14. {
  15. name: 'Alexander',
  16. surname: 'Slobodian',
  17. sex: 'male',
  18. hasAPet: false,
  19. }
  20. ];
  21. let str = "<table>";
  22. for (let key in persons) {
  23. str += "<tr>";
  24. for (let value in persons[key]) {
  25. str += `<td>${persons[key][value]}</td>`;
  26. }
  27. str += "</tr>";
  28. }
  29. str += "</table>";
  30. document.write(str);