Make a Person question about setFirstName

I am stuck here why is getFullName() not returning Haskell Ross?

  **Your code so far**
const Person = function(firstAndLast) {
// Only change code below this line
// Complete the method below and implement the others similarly
let fname = firstAndLast

this.getFullName = function() {
  
return firstAndLast
}
  this.getFirstName =function(){
return firstAndLast.split(" ")[0];
  }
  this.getLastName =function(){
return firstAndLast.split(" ")[1]
  }
  this.setFirstName =function(name){
return name + " " + fname.split(" ")[1]

  }
}

const bob = new Person('Bob Ross');
bob.setFirstName("Haskell")
bob.getFullName()
  **Your browser information:**

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

Challenge: Make a Person

Link to the challenge:

You have defined the method setFirstName to return a string. Don’t you want it to change the value of fname?

I debugged my code and it turned out I was not using the fName for all this functions

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.