Bug Report | Make a Person doesn't test properly

This problem was driving me nuts for sooo long! Turns out the test “You should not reassign first or last variable” isn’t properly implemented. It seems to simply check if the variable I’m assigning ends with “first” or “last”.

I’m confident I’m right about this, because simply adding the N to m_first and m_last causes the solution to pass. If you remove the N, the solution fails. It’s clearly not checking the variable name properly.

This was driving me nuts and confused for days! I simply wouldn’t understand why my solution kept failing! That’s until I made it so m_first and m_last doesn’t end with “first” or “last” by adding N for name.

Please fix this so nobody else runs into this problem.

Your code so far

const Person = function(first, last) {
  
  let m_firstN = first;  //Without the N, the solution fails, because it thinks I'm reassigning.
  let m_lastN = last;   //Without the N, the solution fails, because it thinks I'm reassigning.

  this.getFullName = function() {
    return m_firstN + " " + m_lastN;  //And before you ask, I have tried both removing and adding N in the function bodies.
  };

  this.getLastName = function() {
    return m_lastN;
  };

  this.getFirstName = function() {
    return m_firstN;
  };
  
  this.setFirstName = function(first) {
    return m_firstN = first;
  };

  this.setLastName = function(last) {
    return m_lastN = last;
  };

  this.setFullName = function(first, last) {
    this.setFirstName(first);
    this.setLastName(last);
    return this.getFullName();
  };
};

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0

Challenge Information:

Intermediate Algorithm Scripting - Make a Person

Did you even read what I wrote? If you remove the N in the end of m_firstN and m_lastN as well as in all the function bodies, it doesn’t work! It thinks you’re reassigning first and last despite the m_ in the beginning.

aaah. alright hh I did not notice it,

The same think bro, it did work in both ways !

can u provide the code that crashes, because I tried the code from both sides that u mention and it work just fine.

Really? it didn’t work for me until I added the N. Does anyone know if the test is client-sided or server-sided? If it’s client sided, maybe it doesn’t work the same on all browsers?

can u provide the code that crashes in ur side !

const Person = function(first, last) {
  
  let m_first = first;  //Without the N, the solution fails, because it thinks I'm reassigning.
  let m_last = last;   //Without the N, the solution fails, because it thinks I'm reassigning.

  this.getFullName = function() {
    return m_first + " " + m_last;  //And before you ask, I have tried both removing and adding N in the function bodies.
  };

  this.getLastName = function() {
    return m_last;
  };

  this.getFirstName = function() {
    return m_first;
  };
  
  this.setFirstName = function(first) {
    return m_first = first;
  };

  this.setLastName = function(last) {
    return m_last = last;
  };

  this.setFullName = function(first, last) {
    this.setFirstName(first);
    this.setLastName(last);
    return this.getFullName();
  };
};

Literally the only difference is this is without the N.

The error message you’ve received is likely due to some specific testing or code-checking framework, and it’s possible that there’s a problem with the way the tests are structured or how the code is being evaluated in the testing environment. I think so, I run it now and I see what kind of bug u got.

The two regexs used for the reassignment tests need to be fixed.

I opened an issue for it.

1 Like

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