ob.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.getFullName = function() {
return "Bob Ross";
};
this.getFirstName = function() {
return "Bob";
};
this.getLastName = function() {
return "Ross";
};
this.setFullName = function(firstAndLast) {
return "Bob Ross";
};
this.setFirstName = function(first) {
return "Bob Ross";
};
this.setLastName = function(last) {
return "Bob Ross";
};
};
console.log(bob)
var bob = new Person('Bob Ross');
bob.getFullName();
bob.getFirstName();
bob.getLastName();
bob.setFullName();
bob.setFirstName("Haskell");
bob.setLastName();
/*Intermediate Algorithm Scripting: Make a Person
Fill in the object constructor with the following methods below:
getFirstName()
getLastName()
getFullName()
setFirstName(first)
setLastName(last)
setFullName(firstAndLast)
Run the tests to see the expected output for each method. The methods that take an argument must accept only one argument and it has to be a string. These methods must be the only available means of interacting with the object.
Object.keys(bob).length should return 6.
bob instanceof Person should return true.
bob.firstName should return undefined.
bob.lastName should return undefined.
bob.getFirstName() should return "Bob".
bob.getLastName() should return "Ross".
bob.getFullName() should return "Bob Ross".
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 browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36.
On these types of problems (algorithm), you don’t typically want to return a plain string, you want it so that if you give it a different input, it will change itself.
How may I set that? I am gwting Bob Ross when I should get Haskell Curry. It is not getting modified.
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
let fullName="Bob Ross"
this.getFullName = function() {
return fullName ;
};
let firstName="Bob"
this.getFirstName = function() {
return firstName ;
};
let lastName="Ross"
this.getLastName = function() {
return lastName ;
};
let setFullName="Haskell Curry"
this.setFullName = function() {
return setFullName ;
};
let setFirstName="Haskell"
this.setFirstName = function() {
return setFirstName;
};
let setLastName="Curry"
this.setLastName = function() {
return setLastName ;
};
};
var bob = new Person('Bob Ross');
console.log(bob.getFullName());//should print Haskell Curry bob.setFullName("Haskell Curry")
console.log(bob.setFullName())
/*Intermediate Algorithm Scripting: Make a Person
Fill in the object constructor with the following methods below:
getFirstName()
getLastName()
getFullName()
setFirstName(first)
setLastName(last)
setFullName(firstAndLast)
Run the tests to see the expected output for each method. The methods that take an argument must accept only one argument and it has to be a string. These methods must be the only available means of interacting with the object.
Object.keys(bob).length should return 6.
bob instanceof Person should return true.
bob.firstName should return undefined.
bob.lastName should return undefined.
bob.getFirstName() should return "Bob".
bob.getLastName() should return "Ross".
bob.getFullName() should return "Bob Ross".
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").*/
anyway, the comment in the snippet above is not true
var bob = new Person("Bob Ross");
console.log(bob.getFullName()); // this should print "Bob Ross"
bob.setFullName("Haskell Curry");
console.log(bob.getFullName()); // this should print "Haskell Curry"
I reused the function but I do not know why it does not comply with the next tasks: 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") .
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
this.getFullName = function() {
return firstAndLast.split(" ")[0]+" "+firstAndLast.split(" ")[1] ;
};
this.getFirstName = function() {
return firstAndLast.split(" ")[0] ;
};
this.getLastName = function() {
return firstAndLast.split(" ")[1] ;
};
this.setFullName = function() {
return firstAndLast.split(" ")[0]+" "+firstAndLast.split(" ")[1] ;
};
this.setFirstName = function() {
return firstAndLast.split(" ")[0] ;
};
this.setLastName = function() {
return firstAndLast.split(" ")[1];
};
};
var bob = new Person('Bob Ross');
bob.getFullName();
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
this.getFirstName = function() {
return firstAndLast.split(" ")[0]
};
this.getLastName = function() {
return firstAndLast.split(" ")[1]
};
this.getFullName = function() {
return firstAndLast
};
this.setFirstName = function(first) {
return firstAndLast=first + " "+ this.getLastName()//I am getting here Haskell Ross, what should I change to get "Haskell Ross" when I use bob.getFullName()
};
this.setLastName = function(last) {
return firstAndLast= this.getFirstName() + " "+ last
};
this.setFullName = function(haskellCurry) {
return firstAndLast=haskellCurry
};
};
var bob = new Person('Bob Ross');