Make a person challenge query

So this is my code for that challenge

var Person = function(firstAndLast) {
  // Only change code below this line
  let arr = firstAndLast.split(" ");
  // Complete the method below and implement the others similarly
  this.getFullName = function() {
    let fullName = "";
    for(let i = 0; i < arr.length; i++){
      fullName += arr[i] + " ";
    }
    return fullName;
  };
  
  this.getFirstName = () => arr[0]

  this.getLastName = () => arr[1];
  
  this.setFirstName = function(first){
     return arr[0] = first;
    }

  this.setLastName = last => arr[1] = last;

  this.setFullName = function(firstAndLast){
    let newarr = firstAndLast.split(" ");
    let newFullName = "";
    for(let i = 0; i < newarr.length; i++){
      newFullName += newarr[i] + " ";
    }    
    return newFullName;
  }
  return firstAndLast;
};

All my console log tests show correct results, still the test doesn’t pass. What am i missing?

when you ask for help, please include the challenge link

you may want to check what you are actually returning
in this case you have an extra space
image

Got it! Thanks. And i’ll add the challenge link from next time.

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