These are chat archives for FreeCodeCamp/Help

9th
Mar 2015
Tyler Haas
@tylerthehaas
Mar 09 2015 02:09 UTC

so working on the make person challenge here is my code

var Person = function(firstAndLast) {
var arr = firstAndLast.split(' ');
this.getFirstName = function(){
return arr[0];
};
this.getLastName = function(){
return arr[arr.length - 1];
};
this.getFullName = function(){
return arr.join(' ');
};
this.setFirstName = function(first){
return this.firstName = first;
};
this.setLastName = function(last){
return this.lastName = last;
};
this.setFullName = function(firstAndLast){
return this.fullName = firstAndLast;
};
};

var bob = new Person('Bob Ross');

saying bob.getLastName should equal happy on the tests I'm not understanding what I need to add to pass the tests...seems to work fine when bob ross is passed in

any help pointing me in the right direction would be appreciated
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:10 UTC
You don't want to set get first name to arr[0];
This bonfire is super specific on what it wants which wouldn't make sense in production necessarily
If the program doesn't explicitly call setFirstName, it should be undefined
Tyler Haas
@tylerthehaas
Mar 09 2015 02:11 UTC
should I use object literal notation and use key value pairs instead?
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:11 UTC
the way you are doing it now is fine actually
but for getFirstName it should just return this.firstName
the only thing that should work after creating an instance is the fullName method
until you later change the first or last name
also if you want you can use the || operator to check if this.firstName and this.lastName are set otherwise you can have it choose to return the parameter that was passed
in the fullName method that is
Tyler Haas
@tylerthehaas
Mar 09 2015 02:16 UTC
hmm...so I changed it to that but now the bob ross test arent passing
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:18 UTC
what is your updated code?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:18 UTC
this is my code now
var Person = function(firstAndLast) {
this.getFirstName = function(){
return this.firstName;
};
this.getLastName = function(){
return this.lastName;
};
this.getFullName = function(){
return this.fullName;
};
this.setFirstName = function(first){
return this.firstName = first;
};
this.setLastName = function(last){
return this.lastName = last;
};
this.setFullName = function(firstAndLast){
return this.fullName = firstAndLast;
};
return firstAndLast;
};

var bob = new Person('Bob Ross');
Cristián Berríos
@crisberrios
Mar 09 2015 02:24 UTC
@haasDev when doing a constructor function you don't have to return anything
the function will run on the context of the new object being created
Tyler Haas
@tylerthehaas
Mar 09 2015 02:25 UTC
so take out the returns on all the functions?
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:25 UTC
alright it looks like the tests do care about having first and last set for the first one passed in, just not when you change it
take the last one out
Cristián Berríos
@crisberrios
Mar 09 2015 02:25 UTC
@chrisdziewa did you crack no repeats?
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:25 UTC
haha no.
:worried:
Cristián Berríos
@crisberrios
Mar 09 2015 02:26 UTC
did you understand the pseudo function I wrote?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:26 UTC
wait...take the last what out?
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:26 UTC
the last return statement that was there when you started
Cristián Berríos
@crisberrios
Mar 09 2015 02:27 UTC
 this.setFullName = function(firstAndLast){
return this.fullName = firstAndLast;
};
return firstAndLast;
Suzanne Atkinson
@AdventureBear
Mar 09 2015 02:27 UTC
Chris, I have some advice for you...
Cristián Berríos
@crisberrios
Mar 09 2015 02:27 UTC
the last return statement, and also setFullName is wrong as you are returning an assignment
in fact, you don't need to return anything for setters
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:28 UTC
@crisberrios I kind of do but I apparently am doing everything wrong to it in my recursive case
Cristián Berríos
@crisberrios
Mar 09 2015 02:29 UTC
want to pair?
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:29 UTC
I would love that actually haha
Cristián Berríos
@crisberrios
Mar 09 2015 02:29 UTC
I only have teamviewer
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:30 UTC
I have it but have never used it
would be good to try it
Cristián Berríos
@crisberrios
Mar 09 2015 02:30 UTC
send me your id/pass
Chris Dziewa
@chrisdziewa
Mar 09 2015 02:31 UTC
@AdventureBear haha I've seen that. I had a roommate who loved learning to paint from that guy's videos :P
@haasDev when I'm done pairing if you are still stuck, I can maybe pair with you yet tonight
Tyler Haas
@tylerthehaas
Mar 09 2015 02:33 UTC
var Person = function(firstAndLast) {
this.getFirstName = function(){
return this.firstName;
};
this.getLastName = function(){
return this.lastName;
};
this.getFullName = function(){
return this.fullName;
};
this.setFirstName = function(first){
this.firstName = first;
};
this.setLastName = function(last){
this.lastName = last;
};
this.setFullName = function(firstAndLast){
this.fullName = firstAndLast;
};
};

var bob = new Person('Bob Ross');
thats my code now
what did I need to change with the setFullName method?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:38 UTC
that might be good...thanks for your help
Julie Myers
@BlueOceanView
Mar 09 2015 02:40 UTC
@haasDev did you want to separate your first name from the last name?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:42 UTC
thats what I originally tried but it didn't seem to do the trick
Julie Myers
@BlueOceanView
Mar 09 2015 02:43 UTC
It won't work how it is now because you are only passing in one argument that is named firstAndLast.
Mind if I give it a try?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:46 UTC
please
i got it!!
Julie Myers
@BlueOceanView
Mar 09 2015 02:48 UTC
What did you do?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:49 UTC
added a handler for the errors in the getter methods using the || operator
Julie Myers
@BlueOceanView
Mar 09 2015 02:49 UTC
Could you paste your coding?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:49 UTC
I went on...How do I go back to it?
Julie Myers
@BlueOceanView
Mar 09 2015 02:51 UTC
What software did you type your coding out in?
Tyler Haas
@tylerthehaas
Mar 09 2015 02:53 UTC
nothing just did it directly in bonfire
Julie Myers
@BlueOceanView
Mar 09 2015 02:53 UTC
I learned to do constructor methods this way: using function declarations not function expressions.
function Cat(name, age) {
this.name = name;
this.age = age;
this.meow = function(){
console.log("Meow!");
};
}
var sophia = new Cat("Sophia", 17);
Oh...I dont' think you can get it back in bonfire. No worries.
i'm not saying using function expressions is wrong.
Tyler Haas
@tylerthehaas
Mar 09 2015 02:56 UTC
here:

var Person = function(firstAndLast) {
var arr = firstAndLast.split(' ');
this.getFirstName = function(){
return this.firstName || arr[0];
};
this.getLastName = function(){
return this.lastName || arr[1];
};
this.getFullName = function(){
return this.fullName || firstAndLast;
};
this.setFirstName = function(first){
this.firstName = first;
};
this.setLastName = function(last){
this.lastName = last;
};
this.setFullName = function(firstAndLast){
this.fullName = firstAndLast;
};
};

var bob = new Person('Bob Ross');`
thats the code I used
Yosi
@jparkton
Mar 09 2015 02:57 UTC
and we put a pretty little cloud right here
and some trees
I miss that guy
Tyler Haas
@tylerthehaas
Mar 09 2015 02:58 UTC
I know he was the best...spent a lot of saturday's with him as a kid
Julie Myers
@BlueOceanView
Mar 09 2015 02:58 UTC
Thanks for sharing. That's a neat way to split up the name.
Tyler Haas
@tylerthehaas
Mar 09 2015 02:58 UTC
somehow my pictures never turned out the same...
Yosi
@jparkton
Mar 09 2015 03:03 UTC
Also fun fact before that he was a USMC DI
Kinda funny to imagine him as a DI
Julie Myers
@BlueOceanView
Mar 09 2015 03:08 UTC
Usually once a Marine always a Marine.
Yosi
@jparkton
Mar 09 2015 03:09 UTC
yeah, hard to break out of that brainwashed mentality
Suzanne Atkinson
@AdventureBear
Mar 09 2015 03:11 UTC
@jparkton sometimes your comments seem very confrontational, do you mean them that way?
@BlueOceanView is referring to their internal culture I believe. http://en.wikipedia.org/wiki/United_States_Marine_Corps#Veteran_Marines
Julie Myers
@BlueOceanView
Mar 09 2015 03:12 UTC
@AdventureBear I didn't really take it that way. Some people think that anyone who enters the Marine's get brainwashed to always be a Marine.
Thanks though.
Suzanne Atkinson
@AdventureBear
Mar 09 2015 03:20 UTC
eh, OK, just thought the brainwashed comment was out of place. Who's to say who is brainwashed? Everyone travels their own path.
Julie Myers
@BlueOceanView
Mar 09 2015 03:21 UTC
@AdventureBear Yeah, I see what you mean. I wrote a paper back in college about how word definitions change over time.
How different parts of the country can say the same sentence, but mean different things.
I think all this diversity is what makes making things politically correct so hard.
Chris Dziewa
@chrisdziewa
Mar 09 2015 04:04 UTC
@BlueOceanView your code for a constructor is definitely how I would make an object too ha
that bonfire challenge is so specific
Julie Myers
@BlueOceanView
Mar 09 2015 04:05 UTC
@chrisdziewa :)
Chris Dziewa
@chrisdziewa
Mar 09 2015 04:09 UTC
@haasDev congrats on finishing!
Yosi
@jparkton
Mar 09 2015 04:27 UTC
@BlueOceanView No I know some great people who served I only mean the brainwashed part about those who get all jacked up and gung ho and then never drop the act. There are more who that training turns them into good men, honest men but some come out acting like macho morons
@AdventureBear Yes I do sound confrontational
Julie Myers
@BlueOceanView
Mar 09 2015 04:29 UTC
@jparkton That's cool. I've meet those gung ho types before.
Yosi
@jparkton
Mar 09 2015 04:30 UTC
They leave a lot of people with a bad taste for the marines
but then there are the decent people who used their training to grow, I like them
Julie Myers
@BlueOceanView
Mar 09 2015 04:30 UTC
Yeah. But, I think that is true for any group of people.
Yosi
@jparkton
Mar 09 2015 04:38 UTC
very true
yqyeoh
@yqyeoh
Mar 09 2015 12:36 UTC
anyone has done the bon-fire symmetric difference challenge?
assert.deepEqual(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]), [1, 4, 5], 'should return an array of unique values');AssertionError:should return an array of unique values: expected [ 1, 4 ] to deeply equal [ 1, 4, 5 ]
y should 5 be included?
Luke
@Lukukas
Mar 09 2015 14:00 UTC
yeah, it should. I think this video helps explain it well.
I was definitely confused at first though
Cristián Berríos
@crisberrios
Mar 09 2015 14:06 UTC
good video @Lukukas
yqyeoh
@yqyeoh
Mar 09 2015 14:18 UTC
i see! thanks!!
Tyler Haas
@tylerthehaas
Mar 09 2015 17:45 UTC
anyone know what equation to use to get the orbital period for the map the debris bonfire?
Oliver
@Dadsaster
Mar 09 2015 18:11 UTC
It's the one on wikipedia
Cristián Berríos
@crisberrios
Mar 09 2015 18:12 UTC
^
Oliver
@Dadsaster
Mar 09 2015 18:12 UTC
T = 2\pi\sqrt{a^3/\mu}
That's not quite right but it's what copy and paste gave me.
It's under the heading Small body orbiting a central body
you use average altitude + radius of earth for the major axis value