Intermediate Algorithm Scripting - Make a Person

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

var Person = function(firstAndLast) {
  let firstName = firstAndLast.split(' ')[0];
  let lastName = firstAndLast.split(' ')[1];

  this.getFirstName = function() {
    return firstName;
  };

  this.getLastName = function() {
    return lastName;
  };

  this.getFullName = function() {
    return `${firstName} ${lastName}`;
  };

  this.setFirstName = function(first) {
    firstName = first;
  };

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

  this.setFullName = function(first, last) {
    firstName = first;
    lastName = last;
  };
};

var bob = new Person('Bob Ross');

// Testing the methods
console.log(bob.getFirstName()); // Output: "Bob"
console.log(bob.getLastName());  // Output: "Ross"
console.log(bob.getFullName());  // Output: "Bob Ross"

bob.setFirstName('Haskell');
console.log(bob.getFullName());  // Output: "John Ross"

bob.setLastName('Ross');
console.log(bob.getFullName());  // Output: "John Doe"

bob.setFullName('Haskell Ross');
console.log(bob.getFullName());  // Output: "Jane Smith"

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Make a Person

Link to the challenge:

Hello @gerraldticoalu, welcome to the FCC community. It would help to describe what issues you’re having so that everyone who sees your concern will be able to properly assist you. Ensure to always provide details on the problems you need help or assistance with as this makes it easier for you to get accurate assistance and get it fast.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.