Работая с методом и прототипом, почему этот код не принимается как правильный? - PullRequest
0 голосов
/ 23 января 2020

Инструкции: добавьте метод к прототипу Person с именем «getInitials», который возвращает первую букву их имени и фамилии, обе с большой буквы.

       function Person(firstName, lastName) {
       this.firstName='john';
       this.lastName='doe';

       this.getInitials=function()

       {

       return this.firstName[0].toUpperCase()+this.lastName[0].toUpperCase();

     }
     }

     /* I am instructed not modify code below this line */

    const johnDoe = new Person('john', 'doe');
    console.log(johnDoe.getInitials(), '<-- should be "JD"');
...