Set first, last and full names (Make a Person)

Tell us what’s happening:
I don’t know how to implement “setLastName”, “setFirstName” and “setFullName”. How can I call them? Should I create a “setLastName” function inside the Person function, just like I did with “getLastName”?

here’s what is left to return:
bob.getFullName() should return “Haskell Ross” after bob.setFirstName("Haskell") .

bob.getFullName() should return “Haskell Curry” after bob.setLastName("Curry") .

bob.getFullName() should return “Haskell Curry” after bob.setFullName("Haskell Curry") .

bob.getFirstName() should return “Haskell” after bob.setFullName("Haskell Curry") .

bob.getLastName() should return “Curry” after bob.setFullName("Haskell Curry") .

Your code so far


var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
 this.getFirstName = function() {
  return "Bob";
};
 this.getLastName = function() {
  return "Ross";
};
this.getFullName = function() {
  return "Bob Ross";
};
return firstAndLast;
};

var bob = new Person('Bob Ross');
console.log(bob.getFullName());
console.log(bob.getFirstName());
console.log(bob.getLastName());
console.log(Object.keys(bob).length);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Make a Person

Link to the challenge:

The challenge asks you to create an algorithm that can get the Full name, First name, and Last name. While also having an ability to change the Full name, First name, and Last name. You can’t just return the name. That’s what Algorithm are, it’s purpose is to be able to take certain inputs and returning the needed input.

1 Like

don’t use hardcoded strings. Find a way to use the function parameter to set the name for the first time, and then the functions to change or return it

2 Likes