Tell us what’s happening:
For some reason, the code below hits all the wickets except the challenge “No properties should be added. Object.keys(bob).length
should always return 6.” When I run console.log(Object.keys(bob).length) I get 6 so no idea why it isn’t working.
**Your code so far**
const Person = function (firstAndLast) {
this.getFirstName = function () {
if (this.hasOwnProperty('fullName')) {
return this.fullName.split(' ')[0];
} else {
return firstAndLast.split(' ')[0];
}
};
this.getLastName = function () {
if (this.hasOwnProperty('fullName')) {
return this.fullName.split(' ')[1];
} else {
return firstAndLast.split(' ')[1];
}
};
this.getFullName = function () {
if (this.hasOwnProperty('fullName')) {
return this.fullName;
} else {
return firstAndLast;
}
};
this.setFirstName = function (name) {
this.fullName = firstAndLast;
this.fullName = name + ' ' + this.fullName.split(' ')[1];
};
this.setLastName = function (name) {
this.fullName = firstAndLast;
this.fullName = this.fullName.split(' ')[0] + ' ' + name;
};
this.setFullName = function (name) {
this.fullName = name;
};
};
const bob = new Person('Bob Ross');
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36
Challenge: Make a Person
Link to the challenge: