Intermediate Algorithm Scripting - Make a Person

Getting errors (all shown below code) when I test my code, however, when I test the code to see if I’m actually getting those errors, it works correctly.

My code:

const Person = function(firstAndLast) {
  let firstName = firstAndLast.split(' ')[0];
  let lastName = firstAndLast.split(' ')[1];

  this.getFullName = function() {
    return firstName + " " + lastName;
  };
  this.getFirstName = function() {
    return firstName;
  };
  this.getLastName = function() {
    return lastName;
  };
  this.setFirstName = function(first) {
    return firstName = first;
  };
  this.setLastName = function(last) {
    return lastName = last;
  };
  this.setFullName = function(first, last) {
    this.setFirstName(first);
    this.setLastName(last);
    return this.getFullName();
  };
};

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

The errors I’m getting:

  • You should not change the function signature.
  • The .getLastName() should return the string Ross.
  • The .getFullName() method should return the string Bob Ross.
  • The .getFullName() method should return the string Haskell Ross after calling .setFirstName(‘Haskell’).

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Make a Person

Link to the challenge:

const Person = function(first, last)

Well you can start with the easy one, don’t change this function signature. You’ve changed it to function(firstAndLast) . That will clear the You should not change the function signature. error.

Oh weird, I just reset the lesson to see what the signature is when you begin the lesson and it’s what’s in my code (i.e. const Person = function(firstAndLast), and not const Person = function(first, last)).

Yeah, you have somehow a version of the seed code for the challenge from over a month ago.

I would clear your browser cache.

1 Like

Wow, happy that was discovered quickly, that could have been some nightmare troubleshooting!

const Person = function(first, last) {
this.getFullName = function() {
return “”;
};
return “”;
};

Here’s the template that I get, to confirm.

1 Like

Clearing the browser cache worked, thank you! :pray:

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