var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
first = firstAndLast.split(" ")[0];
second = firstAndLast.split(" ")[1];
this.getFullName = function() {
return first + " " + second;
};
this.getFirstName = function(){
return first;
};
this.getLastName = function(){
return second;
};
this.setFirstName = function(firste){
first = firste;
};
this.setLastName = function(seconde){
second = seconde;
};
this.setFullName = function(firstAndLast){
first = firstAndLast.split(" ")[0];
second = firstAndLast.split(" ")[1];
};
};
var bob = new Person('Bob Ross');
console.log(bob.getFullName());
console.log(Object.keys(bob).length);
console.log(bob instanceof Person);
console.log(bob.getFirstName());
console.log(bob.getLastName());
console.log(bob.getFullName());
bob.setFirstName("Haskell");
console.log(bob.getFullName());
bob.setLastName("Curry");
console.log(bob.getFullName());
console.log(bob.getFirstName());
bob.setFullName("Haskell Curry");
console.log(bob.getLastName());
Here is my node terminal result
$ node advanced.js
Bob Ross
6
true
Bob
Ross
Bob Ross
Haskell Ross
Haskell Curry
Haskell
Curry
You have to get rid of your test code. The only code after your function definition should be
var bob = new Person('Bob Ross');
bob.getFullName();
Also, put var
keywords before your first
and second
variable declarations. It won’t affect your tests, but it’s a good habit to build.
I am sorry I forgot to declare var bob it passed today the same code I checked yesterday. Thank you.