Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a7c5e23

Browse filesBrowse files
committed
[ADD] make a person finished successfully
1 parent 08847eb commit a7c5e23
Copy full SHA for a7c5e23

File tree

Expand file treeCollapse file tree

1 file changed

+26
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-6
lines changed

‎src/makePerson.js

Copy file name to clipboard
+26-6Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
class Person {
2-
constructor(firstAndLast) {
3-
this.getFirstName = () => firstAndLast.slice(0,firstAndLast.indexOf(" "));
4-
this.getLastName = () => firstAndLast.slice(firstAndLast.indexOf(" ") + 1);
5-
this.getFullName = () => firstAndLast;
1+
function Person (firstAndLast){
2+
let names = {
3+
firstName : firstAndLast.slice(0,firstAndLast.indexOf(" ")),
4+
lastName : firstAndLast.slice(firstAndLast.indexOf(" ") + 1)
5+
66
}
7+
8+
this.getFirstName = () => names.firstName;
9+
this.getLastName = () => names.lastName;
10+
this.getFullName = () => `${names.firstName} ${names.lastName}`;
11+
12+
this.setFirstName = (firstName) => {
13+
names.firstName = firstName;
14+
}
15+
this.setLastName = (lastName) => {
16+
names.lastName = lastName;
17+
}
18+
19+
this.setFullName = (firstAndLast) => {
20+
names.firstName = firstAndLast.slice(0,firstAndLast.indexOf(" "));
21+
names.lastName = firstAndLast.slice(firstAndLast.indexOf(" ") + 1);
22+
}
23+
724
}
25+
826

927
const bob = new Person('Bob Ross');
1028
console.log(bob.getFirstName());
11-
console.log(bob.getFullName());
29+
bob.setFirstName("Rass");
30+
console.log(bob.getFirstName());
31+
console.log(Object.keys(bob).length);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.