Intermediate Algorithm Scripting - Make a Person

Tell us what’s happening:
I dont really like that im posting for help for TWO in a row…
personal thing… buuuut…
am i just breaking a semantic somewhere…

:slight_smile:
:woozy_face:
:confounded: :confounded:
:dizzy_face:
:face_with_spiral_eyes:
or have i been i way over assuming the “elasticity” of the foundation i base my confidence in…
aaand i actually just DONT GET what is “getting/setting”
… or have i been completely misreading the problem here?

const Person = function(firstAndLast) {
  let full = firstAndLast;

  this.getFirst = function(){
    return full.split(" ")[0];
  }
  this.getLast = function(){
    return full.split(" ")[1];
  }

  }
  this.getFull = function() {

  return full;
  };

   this.setFirst = function(name) {
    full = name + " " + full.split(" ")[1];
  };

  this.setLast = function(name) {
    fullName = full.split(" ")[0] + " " + name;
  };

  this.setFull = function(name) {
    full = name;
  };
  
const bob = new Person('Bob Ross');
console.log(bob.getFullName())

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36

Challenge: Intermediate Algorithm Scripting - Make a Person

Link to the challenge:

You have a syntax error with your brackets and the method getFullName is not defined.

acctually i made that mistake trying to respond the error i get from this code
:face_with_monocle:
:dizzy_face: :innocent:
:slight_smile:
:100:

const Person = function(firstAndLast) {
  let full = firstAndLast;

  this.getFirst = function(){
    return full.split(" ")[0];
  }
  this.getLast = function(){
    return full.split(" ")[1];
  }

  }
  this.getFull = function() {

  return full;
  };

   this.setFirst = function(name) {
    full = name + " " + full.split(" ")[1];
  };

  this.setLast = function(name) {
    full = full.split(" ")[0] + " " + name;
  };

  this.setFull = function(name) {
    full = name;
  };
  
const bob = new Person('Bob Ross');
console.log(bob.getFull())

^^^^^^^^^^^^^^^^^^^^^^
TypeError: Cannot set properties of undefined (setting ‘getFull’)

actually no i dont

const Person = function(firstAndLast) {
  let full = firstAndLast;
  
  this.getFirst = function(){
    return full.split(" ")[0];
  }
  this.getLast = function(){
    return full.split(" ")[1];
  }

  

  this.getFull = function() {

  return full;
  };

   this.setFirst = function(name) {
    full = name + " " + full.split(" ")[1];
  };

  this.setLast = function(name) {
    full = full.split(" ")[0] + " " + name;
  };

  this.setFull = function(name) {
    full = name;
  };
}
const bob = new Person('Bob Ross');
console.log(bob.getFull())

You were not asked to create a getFull method.

thanx :wink:
:100: :dart:
:palms_up_together::bowing_man:
:pray:
didn’t actually realize i had to name the functions precisely

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