"Make a Person" Challenge, why does (bob instanceof Person) fail?

Hi folks,

I finished up the “Make a Person” challenge, but the bob instanceof Person should return true. test is not passing, if though when I alert bob instanceof Person, it shows true.

Is this a bug?

var Person = function(firstAndLast) {
    firstName = firstAndLast.split(' ')[0];
    lastName = firstAndLast.split(' ')[1];
    
    this.getFirstName = function(){
      return firstName;
    }; 
    this.getLastName = function(){
      return lastName;
    }; 
    this.getFullName = function(){
      return firstName + ' ' + lastName;
    }; 
    this.setFirstName = function(first){
      firstName = first;
    }; 
    this.setLastName = function(last){
      lastName = last;
    }; 
    this.setFullName  = function(firstAndLast){
      firstName = firstAndLast.split(' ')[0];
      lastName = firstAndLast.split(' ')[1];
    };
};
bob = new Person('Bob Ross');

alert(bob instanceof Person); //returns true, which is what the test asks for, fails anyway

@ddvs2012 See this thread: https://forum.freecodecamp.com/t/make-a-person-instanceof-issue/74135

I read that before i posted this, the difference is mine shows that bob instanceof person returns true, which is what the test is asking for.

My bad for not reading thoroughly. Turns out this is caused by removing the word var from before bob. If you change your last line back to var bob = new Person('Bob Ross') it will word. I guess bob needs to be defined as a variable which does make sense. The original code had it as a var, which I found by resetting the code (but don’t do that without copying your current code somewhere! :slight_smile: )

Cheers!

1 Like

That worked! Thanks dhcodes. I hadn’t considered that I’d changed the exact wording of the test, I guess it messed with the testing somehow (though I don’t really understand why). In any case I appreciate your help! :slight_smile: