-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateperson.js
40 lines (35 loc) · 992 Bytes
/
createperson.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
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
let fullName = firstAndLast;
this.getFullName = function() {
return fullName;
};
this.getFirstName = function() {
return fullName.split(' ')[0];
};
this.getLastName = function() {
return fullName.split(' ')[1];
};
this.setFullName = function(firstAndLast) {
fullName = firstAndLast;
return;
};
this.setFirstName = function(firstAndLast) {
let temp = fullName.split(' ');
temp[0] = firstAndLast;
fullName = temp.join(' ')
return;
};
this.setLastName = function(firstAndLast) {
let temp = fullName.split(' ');
temp[1] = firstAndLast;
fullName = temp.join(' ')
return;
};
return firstAndLast;
};
var bob = new Person('Bob Ross');
bob.setFullName('big bill');
console.log(Object.keys(bob));
console.log(bob.setLastName('dolly'))
console.log(bob.getFullName());