main.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
var Person = function (firstAndLast) {
  // Complete the method below and implement the others similarly

  let first = firstAndLast.split(' ')[0]
  let last = firstAndLast.split(' ')[1]
  let fullName = first + ' ' + last

  this.getFirstName = function () {
    return first;
  };
  this.getLastName = function () {
    return last;
  };
  this.getFullName = function () {
    return fullName;
  };

  this.setFirstName = function (firstName) {

    first = firstName
    fullName = firstName + ' ' + last

  };
  this.setLastName = function (lastName) {
    last = lastName
    fullName = lastName + ' ' + last

  };
  this.setFullName = function (both) {
    fullName = both;
    first = both.split(' ')[0]
    last = both.split(' ')[1]

  };

};

var bob = new Person('Bob Ross');
bob.setFirstName('Haskell')
// bob.getFirstName();
// bob.getLastName();
bob.getFullName();

// bob.getFullName() should return "Haskell Ross" after bob.setFirstName("Haskell").
// bob.getFullName() should return "Haskell Curry" after bob.setLastName("Curry").
Native Browser JavaScript