FreeCodeCampChina / freecodecamp.cn

FCC China open source codebase and curriculum. Learn to code and help nonprofits.

Home Page:https://fcc.asia/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Make a Person] has a bug

Kenvas opened this issue · comments

Challenge Make a Person has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

var Person = function(firstAndLast) {
    var firstName="";
    var lastName="";
    this.getFirstName=function(){
        console.log('getFirstName',firstName);
        return firstName;
    };
    this.getLastName=function(){
        console.log('getLastName',lastName);
        return lastName;
    };
    this.getFullName=function(){
        var retval=[firstName, lastName].join(' ');
        console.log('getFullName',retval);
        return retval;
    };
    this.setFirstName=function(x){
        console.log('setFirstName',x);
        firstName=x;
    };
    this.setLastName=function(x){
        console.log('setLastName',x);
        lastName=x;
    };
    this.SetFullName=function(x){
        var arr=x.split(' ');
        console.log('SetFullName', arr);
        firstName=arr[0];
        lastName=arr[1];
    };
    this.SetFullName(firstAndLast);
    return this;
};

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