FreeCodeCampChina / FreeCodeCampChina/freecodecamp.cn

[Make a Person] has a bug

Open
#632 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CSS
Stars
37.8k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

Challenge [Make a Person](https://freecodecamp.cn/challenges/make-a-person#?solution=var%20Person%20%3D%20function(firstAndLast)%20%7B%0A%20%20%20%20var%20firstName%3D%22%22%3B%0A%20%20%20%20var%20lastName%3D%22%22%3B%0A%20%20%20%20this.getFirstName%3Dfunction()%7B%0A%20%20%20%20%20%20%20%20console.log('getFirstName'%2CfirstName)%3B%0A%20%20%20%20%20%20%20%20return%20firstName%3B%0A%20%20%20%20%7D%3B%0A%20%20%20%20this.getLastName%3Dfunction()%7B%0A%20%20%20%20%20%20%20%20console.log('getLastName'%2ClastName)%3B%0A%20%20%20%20%20%20%20%20return%20lastName%3B%0A%20%20%20%20%7D%3B%0A%20%20%20%20this.getFullName%3Dfunction()%7B%0A%20%20%20%20%20%20%20%20var%20retval%3D%5BfirstName%2C%20lastName%5D.join('%20')%3B%0A%20%20%20%20%20%20%20%20console.log('getFullName'%2Cretval)%3B%0A%20%20%20%20%20%20%20%20return%20retval%3B%0A%20%20%20%20%7D%3B%0A%20%20%20%20this.setFirstName%3Dfunction(x)%7B%0A%20%20%20%20%20%20%20%20console.log('setFirstName'%2Cx)%3B%0A%20%20%20%20%20%20%20%20firstName%3Dx%3B%0A%20%20%20%20%7D%3B%0A%20%20%20%20this.setLastName%3Dfunction(x)%7B%0A%20%20%20%20%20%20%20%20console.log('setLastName'%2Cx)%3B%0A%20%20%20%20%20%20%20%20lastName%3Dx%3B%0A%20%20%20%20%7D%3B%0A%20%20%20%20this.SetFullName%3Dfunction(x)%7B%0A%20%20%20%20%20%20%20%20var%20arr%3Dx.split('%20')%3B%0A%20%20%20%20%20%20%20%20console.log('SetFullName'%2C%20arr)%3B%0A%20%20%20%20%20%20%20%20firstName%3Darr%5B0%5D%3B%0A%20%20%20%20%20%20%20%20lastName%3Darr%5B1%5D%3B%0A%20%20%20%20%7D%3B%0A%20%20%20%20this.SetFullName(firstAndLast)%3B%0A%20%20%20%20return%20this%3B%0A%7D%3B%0A%0Avar%20bob%20%3D%20new%20Person('Bob%20Ross')%3B%0A) 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:
```javascript
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');

```

Contributor guide

Open the contributing guide

Research direction

Open the linked Make a Person challenge and compare its expected behavior with the supplied Person implementation. Reproduce the reported problem using the included Bob Ross example; the issue is done when the faulty challenge or reproduction is clearly identified and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
content
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.