-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakeAPerson.js
58 lines (50 loc) · 1.43 KB
/
MakeAPerson.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
this.getFullName = function() {
return firstAndLast;
};
this.getFirstName= function(){
var nameArr =[];
nameArr=firstAndLast.split(" ");
var first = nameArr[0];
return first;
};
this.getLastName= function(){
var nameArr =[];
nameArr=firstAndLast.split(" ");
var last = nameArr[1];
return last;
};
this.setFirstName= function(first){
var nameArr =[];
nameArr=firstAndLast.split(" ");
nameArr[0]= first;
firstAndLast = (nameArr[0]+" "+nameArr[1]);
return firstAndLast;
};
this.setLastName= function(last){
var nameArr =[];
nameArr=firstAndLast.split(" ");
nameArr[1]= last;
firstAndLast = (nameArr[0]+" "+nameArr[1]);
return firstAndLast;
};
this.setFullName= function(fullname){
firstAndLast = fullname;
return firstAndLast;
};
return firstAndLast;
};
var bob = new Person('Bob Ross');
console.log(bob.getFullName());
console.log(bob.getFirstName());
console.log(bob.getLastName());
bob.setFirstName("Tim");
console.log(bob.getFirstName());
console.log(bob.getFullName());
bob.setLastName("Murphy");
console.log(bob.getLastName());
console.log(bob.getFullName());
bob.setFullName("Jim Jones");
console.log(bob.getFullName());
//setFullName(firstAndLast); this.setLastName= function(last){