Intermediate Algorithm Scripting - Make a Person

Hello everybody, just quick question, could someone tell me why this works for every check except for :

" bob.getFullName() should return the string Haskell Curry after bob.setLastName("Curry") ."

Thanks in advance…

const Person = function(firstAndLast) {
  // Only change code below this line
  // Complete the method below and implement the others similarly

    let arr = {
      firstName: "Bob",
      lastName: "Ross",

  this.getFirstName = function() {
    return arr.firstName;

  this.getLastName = function() {
    return arr.lastName;

  this.getFullName = function() {
    return arr.firstName + " " + arr.lastName;

 this.setFirstName = function(y) {
    arr.firstName = y;

    this.setLastName = function(z) {
    arr.lastName = z;

  this.setFullName = function(x) {
    let value = x.split(" ")
    arr.firstName = value[0];
    arr.lastName = value[1];
    return arr.firstName + " " + arr.lastName;
  //return firstAndLast;

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

const bob = new Person('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:

Just quick add, it works when you console log my code, but check wont accept this.

Why do you have this in your code? What would happen if someone created a new Person with a completely different name?

You should take whichever name is supplied to the function parameter firstAndLast and manipulate that to create the getter and setter methods. Your code ignores the firstAndLast parameter altogether and bases the methods only on the value of arr, which you’ve created yourself.

thank you for explaining it to me, i think i need to better understand this.

You could take firstAndLast and manipulate that directly in your code.
For example, what would happen if you declared an arr variable, which used the split method on firstAndLast, instead of the arr variable you have already?

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