1.要求
2.思路
3.代码
var Person = function(firstAndLast) {
var firstName=firstAndLast.split(' ')[0];
var lastName=firstAndLast.split(' ')[1];
this.getFirstName=function(){
return firstName;
};
this.getLastName=function(){
return lastName;
};
this.getFullName=function(){
return firstName+' '+lastName;
};
this.setFirstName=function(first){
firstName=first;
};
this.setLastName=function(last){
lastName=last;
};
this.setFullName=function(firstAndLast){
firstName=firstAndLast.split(' ')[0];
lastName=firstAndLast.split(' ')[1];
};
return firstAndLast;
};
var bob = new Person('Bob Ross');
bob.getFullName();
4.相关链接
Make a Person-freecodecamp算法题目
原文:https://www.cnblogs.com/ahswch/p/9307751.html