Why my algorithm fails?

Only one test fails, but I would like to have the technical explanation about this issue to understand JS syntax.

Thanks in advance.

Regards


let Person = function (firstAndLast) {
let fullName = firstAndLast;
this.getFirstName = () => fullName.split(" ")[0];
this.getLastName = () => fullName.split(" ")[1];
this.getFullName = () => fullName;
this.setFirstName = (name) => fullname = name + " " + fullName.split(" ")[1];
this.setLastName = (name) => fullName = fullName.split(" ")[0] + " " + name;
this.setFullName = (name) => fullName = name;
};

var bob = new Person('Bob Ross');
bob.getFullName();
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0

Challenge: Make a Person

Link to the challenge:

Which test is failing

Thanks Jeremy for your kind attention.

The test which is returning error is:

`bob.getFullName()` should return the string `Haskell Ross` after `bob.setFirstName("Haskell")` ..

I’ve tried to put in those function calls (it’s not a bad idea to try when a test fails), and here is what the console say:
image

2 Likes

I see now that my error was in this line

this.setFirstName = (name) => **fullname** = name + " " + fullName.split(" ")[1];

Thanks so much Ilenia.

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