I commented out my own tests so they would not interfere with the automatic tests and I still get:
// running tests
bob.getFirstName() should return “Bob”.
bob.getLastName() should return “Ross”.
bob.getFirstName() should return “Haskell” after bob.setFullName(“Haskell Curry”).
bob.getLastName() should return “Curry” after bob.setFullName(“Haskell Curry”).
// tests completed
NB I append ‘*’ in my tests to check for trailing spaces (there are none)
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
var fullName = firstAndLast;
this.getFullName = function() {
return fullName;
};
this.setFullName = function(firstAndLast) {
fullName = firstAndLast;
}
this.getFirstName = function() {
return fullName.match(/^\w+/);
}
this.setFirstName = function(fName) {
fullName = fName + fullName.replace(/^\w+/,'');
}
this.getLastName = function() {
return fullName.match(/\w+$/);
}
this.setLastName = function(fName) {
fullName = fullName.replace(/\w+$/,'') + fName;
}
};
var bob = new Person('Bob Ross');
/*
console.log(Object.keys(bob).length);
console.log(bob instanceof Person);
console.log(`bob.lastName:${bob.firstName}`);
console.log(`bob.lastName:${bob.lastName}`);
var testBob = new Person('Bob Ross');
console.log(testBob.getFirstName()+'*');
console.log(testBob.getLastName()+'*');
console.log(testBob.getFullName()+'*');
testBob.setFirstName("Haskell");
console.log(testBob.getFullName()+'*');
testBob.setLastName("Curry");
console.log(testBob.getFullName()+'*');
testBob.setFullName("Haskell Curry")
console.log(testBob.getFullName()+'*');
console.log(testBob.getFirstName()+'*');
console.log(testBob.getLastName()+'*');
*/