Make-a-person Test not passing in fcc, help!

Tell us what’s happening:
Hi, my code is not passing get method tests in fcc, however, they are producing the required output in chrome developer console and replit. Please help.
link :replit link
[Edit]: I have tried changing my code but still no luck. Anybody facing similar problem? Could it be an FCC bug or am I just doing something wrong here?

Updated code:
Your code so far


///////////////////////////////////////////////////////
/**Exercise: Fill in the object constructor with the following methods below:
  
	//getFirstName() getLastName() getFullName() setFirstName(first) setLastName(last) setFullName(firstAndLast)//

Run the tests to see the expected output for each method.

The methods that take an argument must accept only one argument and it has to be a string.These methods must be the only available means of interacting with the object.
*/
////////////////////////////////////////////////////////
/**Note:  Commented Out console.log() are for debugging only. */
//Function
var Person = function(firstAndLast) {

	//Variable Declarations
	var nameArray =  firstAndLast.split(" "); // private property

	/**publicly available method Get Methods */
  this.getFullName = function() {
    return nameArray.join(" ");
  };
	this.getFirstName = function() {
    return nameArray[0];
  };
	this.getLastName = function() {
    return nameArray[1];
  };

	/**publicly available method Set Methods */
  this.setFullName = function(firstAndLast) {
    nameArray = firstAndLast.split(" ");
  };
	this.setFirstName = function(first) {
    nameArray[0] = first;
  };
	this.setLastName = function(last) {
    nameArray[1] = last;
  };
};

//Tests
/*Object bob created from person constructor function*/
var bob = new Person('Bob Ross');
console.log("_____________________________________");
console.log("bob instanceof Person: ", bob instanceof Person);//return true
/*Number of keys of the Object bob*/
console.log("_____________________________________");
console.log("Object.keys(bob).length: ", Object.keys(bob).length);//return 6
/*private property of object bob*/
console.log("_____________________________________");
console.log("bob.nameArray: ", bob.nameArray);//return undefined
/*public get methods of object bob*/
console.log("_____________________________________");
console.log("bob.getFullName(): ", bob.getFullName());//return "Bob Ross"
console.log("bob.getFirstName(): ", bob.getFirstName());//return "Bob"
console.log("bob.getLastName(): ", bob.getLastName());//return "Ross"
/*public set methods of object bob*/
console.log("_____________________________________");
bob.setFirstName("Haskell")
console.log("bob.setFirstName(\"Haskell\");");
console.log("bob.getFirstName(): ", bob.getFirstName());//return "Haskell"
console.log("bob.getLastName(): ", bob.getLastName());//return "Ross"
console.log("bob.getFullName(): ", bob.getFullName());//return "Haskell Ross"
console.log("_____________________________________");
bob.setLastName("Curry");
console.log("bob.setLastName(\"Curry\");");
console.log("bob.getFirstName(): ", bob.getFirstName());//return "Haskell"
console.log("bob.getLastName(): ", bob.getLastName());//return "Curry"
console.log("bob.getFullName(): ", bob.getFullName());//return "Haskell Curry"
console.log("_____________________________________");
bob.setFullName("Harry Potter");
console.log("bob.setFullName(\"Harry Potter\");");
console.log("bob.getFirstName(): ", bob.getFirstName());//return "Harry"
console.log("bob.getLastName(): ", bob.getLastName());//return "Potter"
console.log("bob.getFullName(): ", bob.getFullName());//return "Harry Potter"
console.log("_____________________________________");

Your browser information:

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

Link to the challenge:

Updated Chrome console output:

Can you unblur your code so that I can copy it and paste it to see what’s going on?

Okay I removed the blur

is anyone facing a similar problem?

Your code passes for me. Try clearing your browser cookies. If that fails, try a different browser.

Remove the logs you added, and try again.

Why?
Because your calls to variable bob changes its state, and for very first test, FCC expects “Bob Ross” while it’s not,
instead it’s Harry Potter

Fact: your code (including logs you add) are called first, then FCC tests. Here FCC expected the variable is initialized as var bob = new Person("Bob Ross"); (where state and value for first test is “Bob Ross”).
So as you called set first name and last name of bob, and changed its state, then FCC test for first tries fail.

Tip: instead of changing the bob, create another variable like var my_bob = new Person("Bob Ross"); and works on it with your log, leave the bob as it is.

Keep going on great work, happy coding.

1 Like

Thank you!! that solved the problem.:+1::grinning: