freecodecamp.cn
freecodecamp.cn copied to clipboard
304号挑战,满足了所有要求,Run tests的时候代码控制台一直testing challenge
打开chrome控制台,有这么一条错误信息:
TypeError: Cannot read property 'split' of undefined
*报错的位置并不是我的代码,这妥妥是freecodecamp的BUG吧! 浏览器: chrome(70.0.3538.77) My code:
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');