Make a Person: Passing 11/12

Tell us what’s happening:
Could someone tell me why the following code is not passing this requirement:

Requirement: bob.getFullName() should return “Haskell Curry” after bob.setLastName("Curry")

I’m passing every other requirement of this challenge.

Your code so far


var Person = function(firstAndLast) {
// Only change code below this line
// Complete the method below and implement the others similarly
var fullName = firstAndLast

this.getFullName = function() {
  return fullName;
}
this.getFirstName = function(){
  return fullName.split(" ")[0];
}
this.getLastName = function(){
  return fullName.split(" ")[1];
}

this.setFirstName = function(newName){
  return fullName = newName + " " + this.getLastName();
}
this.setLastName = function(newName){
  return fullname = this.getFirstName() + " " + newName;
  
}
this.setFullName = function(newName){
  return fullName = newName;
}



};



var bob = new Person('Bob Ross');

Your browser information:

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

Challenge: Make a Person

Link to the challenge:

You have a typo. Hint: It is in the setter.

2 Likes

Everything looks good in the code except for your this.setLastName function.

It’s a very minor error, but you’ll want to double-check the variable you’re returning and compare it with the other returns that you have in other functions.

2 Likes

Thank you both. I should have spotted that… :sweat_smile:

if you write

bob.setFirstName("Haskell");
bob.setLastName("Curry");
let result = bob.getFullName();
console.log(result)

what do you see in the console?