-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-a-person.js
More file actions
38 lines (33 loc) · 800 Bytes
/
make-a-person.js
File metadata and controls
38 lines (33 loc) · 800 Bytes
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
/*
Fill in the object constructor with the following methods below:
getFirstName()
getLastName()
getFullName()
setFirstName(first)
setLastName(last)
setFullName(firstAndLast)
*/
var Person = function(firstAndLast) {
this.getFirstName = () => {
let first = firstAndLast.split(" ")[0];
return first;
}
this.getLastName = () => {
let last = firstAndLast.split(" ")[1];
return last;
}
this.getFullName = () => {
return firstAndLast;
};
this.setFirstName = (name) => {
firstAndLast = firstAndLast.replace(this.getFirstName(), name);
};
this.setLastName = (name) => {
firstAndLast = firstAndLast.replace(this.getLastName(), name);
};
this.setFullName = (name) => {
firstAndLast = name;
};
};
var bob = new Person('Bob Ross');
bob.getFullName();