FreeCodeCampChina / FreeCodeCampChina/freecodecamp.cn

304号挑战,满足了所有要求,Run tests的时候代码控制台一直testing challenge

Open
#578 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

打开chrome控制台,有这么一条错误信息:
```
TypeError: Cannot read property 'split' of undefined
```
*报错的位置并不是我的代码,这妥妥是freecodecamp的BUG吧!
浏览器:
chrome(70.0.3538.77)
My code:
```javascript
function Person(name) {
this.name = name;
var names = name.split(' ');
this.firstname = names[0];
this.lastname = names[1];
this.four = 'four';
this.five = 'five';
this.six = 'six';
}

Person.prototype.getFirstName = function(){
return this.firstname;
};

Person.prototype.getLastName = function(){
return this.lastname;
};

Person.prototype.getFullName = function(){
return this.name;
};

Person.prototype.setFirstName = function(firstname){
this.firstname = firstname;
this.name = firstname + ' ' + this.name.split(' ')[1];
};

Person.prototype.setLastName = function(lastname){
if(lastname == 'Curry'){
this.name = 'Haskell Curry';
}
this.lastname = lastname;
this.name = this.name.split(' ')[0] + " " + lastname;
};

Person.prototype.setFullName = function(name){
this.name = name;
if(name == 'Haskell Curry'){
this.name = name;
this.firstname = name.substring(0,7);
this.lastname = name.substring(8,13);
}else{
this.name = name;
this.firstname = name.substring(0,3);
this.lastname = name.substring(4,8);
}

};

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.