hw11_01_create_person.html 654 B

123456789101112131415161718192021
  1. <head>create person</head>
  2. <body>
  3. <script>
  4. let createPerson = function (name, surname) {
  5. let result = { 'name': name, 'surname': surname };
  6. result.getFullName = function () {
  7. return `${this.name} ${this.surname}`;
  8. }
  9. return result;
  10. }
  11. const a = createPerson("Вася", "Пупкин")
  12. const b = createPerson("Анна", "Иванова")
  13. const c = createPerson("Елизавета", "Петрова")
  14. console.log(a.getFullName())
  15. a.fatherName = 'Иванович'
  16. console.log(b.getFullName())
  17. </script>
  18. </body>