Make a Person ,can't find the fault

Make a Person ,can't find the fault
0

#1

Tell us what’s happening:
It seems correct,but it can’t pass.

Your code so far


var Person = function(firstAndLast) {
 
  let name = firstAndLast.split(' ');
   
  this.getFullName = function() {
    return name[0] + ' ' + name[1];
  };
  this.getFirstName= function(){
  	return  name[0];
  }; 
  this.getLastName= function(){
  	return  name[1];
  };  

  this.setFirstName= function(first){
  	name[0] = first;
  };  
  this.setLastName= function(last){
  	name[1] = last;
  };  
  this.setFullName= function(firstAndLast){
  	name[0]=firstAndLast.split(' ')[0];
  	name[1]=firstAndLast.split(' ')[1];
  }; 
};

var bob = new Person('Bob Ross');
//bob.setLastName('Curry');
//bob.setFirstName('Haskell');
console.log(bob.getFirstName());
console.log(bob.getLastName());
console.log(bob.getFullName());

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person/2


#2

Weird, it works for me…

Have you tried it on Chrome?


#3

Yes,I tried.And it is the only browser that I use.


#5

No need to thank me. Idk what you did but congrats!


#6

Emmm…Now, it works well.Thank you!


#7

Keep at it. I wish you the best of luck!


#8

It happened to me, too. You need to delete or comment the lines where you wrote:

bob.setFirstName(“Haskell”);
bob.setLastName(“Curry”);
bob.setFullName(“Haskell Curry”);

When you run your code in browser it interprets it line after line, and it works well. But for some reason their tests don’t run like that, and it can’t pass.