8_fullName.js 555 B

12345678910111213141516171819202122232425262728
  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. for (let key in persons) {
  22. if('name' in persons[key] && 'surname' in persons[key] && 'middleName' in persons[key]) {
  23. persons[key].fullName = `${persons[key].surname} ${persons[key].name} ${persons[key].middleName}`;
  24. }
  25. }
  26. console.log(persons);