Make a Person: Why should setLastName result in a different first name as well?

Tell us what’s happening:
Describe your issue in detail here.

I am getting the error on the following test
“bob.getFullName() should return the string “Haskell Curry” after bob.setLastName(“Curry”)”

Why isn’t the expected result “Bob Curry”? The only explanation I could think of is if it is expecting the previous tests effects to remain for this test. The last few lines of my code however show that after setting first name to haskell and then separately setting the last name to curry I do get Haskell Curry.
My console displays

Haskell Ross
Haskell Curry
Bob 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 sur = firstAndLast.split(" ")[1];
  let given = firstAndLast.split(" ")[0];
    this.getFullName = function() {
    return given + " " + sur;
    this.getFirstName = function() {
      return given;
    this.getLastName = function() {
      return sur;
    this.setLastName = function(last) {
      sur = last;
    this.setFirstName = function(first){
      given = first;
    this.setFullName = function(firstAndLast){
      sur = firstAndLast.split(" ")[1];
      given = firstAndLast.split(" ")[0];

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

// Tests if it's failing becuase it doesn't update properly in a sequence
bob.setFullName("Bob Ross");

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Make a Person

Link to the challenge:

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