What am i getting wrong?
ayormeday (9)

Add a method to the Person's prototype called "getInitials" that returns the first letter of their first and last name, both capitalized.

function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
person.prototype.getInitials = function (person){
var names = person.split(' '),
initials = names[0].substring(0, 1).toUpperCase();

if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
console.log(initials);
}

/ Do not modify code below this line /

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

You are viewing a single comment. View All
Answered by vedprad1 (726) [earned 5 cycles]
View Answer
ayormeday (9)

@vedprad1 is there anyway I can keep in touch with you on further problems?