What am i getting wrong?
ayormeday (10)

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();

/ 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 (864) [earned 5 cycles]
View Answer
vedprad1 (864)

@MIAlien : You should post it in another post, because it is a different question.