Tell us what’s happening:
My code seems to work as intended. However, the test won’t pass at the line bob.getFirstName()
should return “Haskell” after bob.setFullName("Haskell Curry")
I’ve manually tested my code to see if there’s anything wrong but everything works as it should. Am I doing something wrong or is it just some kind of bug? Help please.
Your code so far
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
var nameArr = firstAndLast.split(' ');
this.setFirstName = (first) => nameArr[0] = first;
this.setLastName = (last) => nameArr[1] = last;
this.setFullName = (firstLast) => {
nameArr[0] = firstLast.match(/\w+/);
nameArr[1] = firstLast.substring(firstLast.indexOf(" ") + 1);
}
this.getFirstName = () => nameArr[0];
this.getLastName = () => nameArr[1];
this.getFullName = () => `${nameArr[0]} ${nameArr[1]}`
};
var bob = new Person('Bob Ross');
bob.getFullName();
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge: