Hi, there is something wrong with my advanced algorithm and I cannot seem to figure out what. I haven’t looked at any solutions for this and I’m trying my best not to. I’ve got every one of the tests of this algorithm right except where “bob instanceof Person” should return “true”; I just don’t understand what is wrong with my code. I’m sure it’s something blatantly obvious. Please help. Thanks.
var Person = function(firstAndLast) {
var arr = firstAndLast.split(" ");
return {
getFirstName: function(){
return arr[0];
},
getLastName: function(){
return arr[1];
},
getFullName: function(){
return arr.join(" ");
},
setFirstName: function(val){
arr[0] = val;
return arr;
},
setLastName: function(val){
arr[1] = val;
return arr;
},
setFullName: function(val){
newArr = val.split(" ");
arr[0] = newArr[0];
arr[1] = newArr[1];
return arr;
}
};
};
var bob = new Person("Bob Ross");
console.log(Person instanceof Object); //returns true
console.log(Person instanceof Function); //returns true
console.log(bob instanceof Object); //returns true
console.log(bob instanceof Person); //returns false