Tell us what’s happening:
I don’t understand why my third to last test is passing but the others aren’t? I’ve checked my if statements and conditionals. I don’t see the problem.
Your code so far
var Person = function (firstAndLast) {
// Complete the method below and implement the others similarly
this.getFullName = function () {
return this.firstName + " " + this.lastName;
};
this.getFirstName = function(){
this.firstName = firstAndLast.split(" ")[0];
return this.firstName;
};
this.getLastName = function(){
this.lastName = firstAndLast.split(" ")[1];
return this.lastName;
};
this.setFirstName = function(first){
// short-circuit and
if(arguments.length !== 1 && typeof first !== 'string'){
return
}
this.firstName = first;
}
this.setLastName = function(last){
// short circuit and
if(arguments.length !== 1 && typeof last !== 'string'){
return
}
this.lastName = last;
}
this.setFullName = function(firstAndLast){
// short circuit and
if(arguments.length !== 1 && typeof firstAndLast !== 'string'){
return
}
this.firstName = firstAndLast.split(" ")[0];
this.lastName = firstAndLast.split(" ")[1];
}
};
var bob = new Person('Bob Ross');
bob.getFullName();
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
.
Link to the challenge: