Object keys in constructor

Hello guys, I guess I do not clearly get what is meant by " Object.keys(bob).length should return 6" which is one of the points that I need to pass. In my code below I pass every single challenge but not the first one. What is meant by those keys? Are those keys meant like keys from an object or?

  **My code so far**

var Person = function(firstAndLast) {
// Only change code below this line
this.details = {
  "firstName": firstAndLast.split(" ")[0],
  "lastName": firstAndLast.split(" ")[1],
}
this.getFirstName = function(){
  return this.details["firstName"]
}
this.getLastName = function(){
  return this.details["lastName"]
}
this.setFirstName = function(newFirstName){
  this.details["firstName"] = newFirstName
}
this.setLastName = function(newLastName) {
  this.details["lastName"] = newLastName
}
this.setFullName = function(newFullName) {
  this.details["firstName"] = newFullName.split(" ")[0]
  this.details["lastName"] = newFullName.split(" ")[1]
}
// Complete the method below and implement the others similarly
this.getFullName = function() {
  return this.details["firstName"] + " " + this.details["lastName"];
};
};

var bob = new Person('Bob Ross');
bob.getFullName();
bob.setFirstName("Haskell");
bob.getFullName();
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36

Challenge: Make a Person

Link to the challenge:

if you log in the console Object.keys you can see that your object has 7 keys instead of six
image

This goes against the requirement

These methods must be the only available means of interacting with the object.

1 Like

Oh. I feel like an idiot xD. I do not know why I did not write this do have an idea what could be wrong. I have done it again and now I passed the challenge. Thank you very much.

So in the end object key is something that looks like this “this. something”? Then object value would be everything that is referred to with the object key?

an object is made of key: value pairs
you are accessing/creating them using dot notation in your function, and using the keyword this to refer to the object itself

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.