Values are showing up as undefined in constructors ...?

Tell us what’s happening:
Describe your issue in detail here.
Values are showing up as undefined …?

getFullName: undefined
undefined
  **Your code so far**
var Person = function(firstAndLast) {
  // Only change code below this line
  // Complete the method below and implement the others similarly
  
  this.setFullName = function(firstAndLast) {
    this.fullName=firstAndLast;
    console.log('setFullName:',this.fullName);
  };
  

  this.setFirstName = function(first) {
    this.firstName=first;
    console.log('setFirstName:',this.firstName);
  };

  this.setLastName = function(last) {
    this.lastName=last;
    console.log('setLastName:',this.lastName);
  };

  

  this.getFullName = function() {
    console.log('getFullName:',this.fullName);
    return this.fullName;
  };

  this.getFirstName = function() {
    return this.fullName.split(' ')[0];
  };

  this.getLastName = function() {
    return this.fullName.split(' ')[1];
  };


  return this.fullName;
};

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

console.log(bob.getFullName());


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

this.setFullName = function(firstAndLast) {
  this.fullName=firstAndLast;
  console.log('setFullName:',this.fullName);
};


this.setFirstName = function(first) {
  this.firstName=first;
  console.log('setFirstName:',this.firstName);
};

this.setLastName = function(last) {
  this.lastName=last;
  console.log('setLastName:',this.lastName);
};



this.getFullName = function() {
  console.log('getFullName:',this.fullName);
  return this.fullName;
};

this.getFirstName = function() {
  return this.fullName.split(' ')[0];
};

this.getLastName = function() {
  return this.fullName.split(' ')[1];
};


return this.fullName;
};

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

console.log(bob.getFullName());
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36.

Challenge: Make a Person

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

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