These are chat archives for FreeCodeCamp/Help

8th
Apr 2015
Christopher Hutchinson
@cshutchinson
Apr 08 2015 02:52
can anyone provide some assistance sharing a piece of data between two react forms in a vanilla flux environment?
like a username that need to be provided to a secondary form
the secondary form is loaded by react router when this line is called:
window.location.href = '/signup/musicianDetailsForm’;
i thought to transfer the info in a parameter on this url using aspects of react router but hoped not to do that
Quincy Larson
@QuincyLarson
Apr 08 2015 05:14
@cshutchinson I don’t know much about React. You might try the react IRC room. Log into https://webchat.freenode.net/ and /join react
Christopher Hutchinson
@cshutchinson
Apr 08 2015 06:16
this helped me figure it out….. http://blog.andrewray.me/flux-for-stupid-people/
flux for stupid people LOL
Cristián Berríos
@crisberrios
Apr 08 2015 06:40
nice resource @cshutchinson
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 09:15
Need some help with a personal project
Renzo Poddighe
@rpoddighe
Apr 08 2015 10:57
@AmmarAliShah What do you need?
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:40
@rpoddighe Are you still here?
Need some suggestions
Relating to a book website
Renzo Poddighe
@rpoddighe
Apr 08 2015 11:41
@AmmarAliShah Yes I'm still here
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:42
Okay so it's related to http://ammaralishah.github.io/work/RHQ
If you scroll down you'll see the chapter section
And in the Navbar the Rooh-Ul-Quran link
I need to add a reader there to read a PDF file
any recommendations?
Ben McMahon
@benmcmahon100
Apr 08 2015 11:44
@AmmarAliShah browsers automatically handle pdfs for you
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:44
No I want it to look like a book reader
the chapters section needs to link to specific areas in the book
and the link area needs to open up the book in a kind of a reader
Ben McMahon
@benmcmahon100
Apr 08 2015 11:45
@AmmarAliShah issuu works well enough and I think it's what you want
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:46
@benmcmahon100 Can I integrate it inside the website?
Ben McMahon
@benmcmahon100
Apr 08 2015 11:46
yes you can embed them like youtube videos
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:47
oh and chapter linking too right?
Ben McMahon
@benmcmahon100
Apr 08 2015 11:47
I'm fairly sure
yes you can as you can modify the viewer using javascript
if you go to the developer section you'll see what i mean
@AmmarAliShah E.G. viewer.setPageNumber(207):void with 207 being the start fo chapter 8 etc.
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:49
@benmcmahon100 oh thanks a lot!
Ben McMahon
@benmcmahon100
Apr 08 2015 11:50
@AmmarAliShah No problem! If you have any trouble with the dev api do ask again here! :p
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:50
@benmcmahon100 Yeah I will be sure to
Renzo Poddighe
@rpoddighe
Apr 08 2015 11:50
@AmmarAliShah I'll have a look, but it sounds like @benmcmahon100 already found a solution :)
Ben McMahon
@benmcmahon100
Apr 08 2015 11:52
just a happy coincidence that I had to get something done like this before! :p
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:53
@benmcmahon100 Well I'm doing this for free
Ben McMahon
@benmcmahon100
Apr 08 2015 11:54
@AmmarAliShah I was the same when i needed to find a solution for display a PDF like that.
Ammar Ali Shah
@AmmarAliShah
Apr 08 2015 11:56
@benmcmahon100 yeah just created an account
Briana Swift
@brianamarie
Apr 08 2015 18:41
I don't understand what's wrong with the return statement. (I know there are minor kinks in the original function that I'm planning on working out after this problem). It says "Illegal Return Statment" when I expected it to say "Bob Ross". Can anyone help me understand why?
http://www.freecodecamp.com/bonfires/make-a-person
var Person = function(firstAndLast) { 
  this.firstName = ("firstname"); 
  this.lastName = ("lastname");
  this.fullName = firstAndLast.toString(); 
};

(function() {
  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(full){
    this.fullName = full; 
  };

}).call(Person.prototype);


var bob = new Person('Bob Ross');
return bob.getFullName();
Justin
@abigsmall
Apr 08 2015 18:42
is that all inside a function?
Briana Swift
@brianamarie
Apr 08 2015 18:42
Nope. I'm attempting to use closures
So actually yes, it's inside several functions
Justin
@abigsmall
Apr 08 2015 18:46
I ask because if you have a return statement just in the global scope it gives the same error of “Illegal Return Statement”
Briana Swift
@brianamarie
Apr 08 2015 19:45
Ah. At the end I need to delete the "return" before "bob.getFullName();"...among plenty of other issues, that's just the one I was trying to debug first :)
Briana Swift
@brianamarie
Apr 08 2015 20:01
Same bonfire, different bug. I'm not getting a correct test case for two of the user tests. I'm not quite sure why/what it's asking or expecting. I think that it's trying to check that those methods WON'T work, but instead of returning "undefined" it returns "string is not a function". Anybody have any tips on how to resolve this?
http://www.freecodecamp.com/bonfires/make-a-person
var Person = function(firstAndLast) { 
  var nameArr = firstAndLast.split(' ');
  this.firstName = nameArr[0];
  this.lastName = nameArr[1];
  this.fullName = firstAndLast.toString(); 
  this.setFirst = 0;
  this.setLast = 0; 
  this.setFull = 0; 
};

Person.prototype.getFirstName = function(){
  return this.firstName;
};

Person.prototype.getLastName = function(){
  return this.lastName;
};

Person.prototype.getFullName = function(){
  return this.fullName;
};

Person.prototype.setFirstName = function(first){
    this.firstName = first;
};

Person.prototype.setLastName = function(last){
    this.lastName = last;
};

Person.prototype.setFullName = function(full){
    this.fullName = full; 
};


var bob = new Person('Bob Ross');
(bob.getFirstName());
Ben McMahon
@benmcmahon100
Apr 08 2015 20:20
@brianamarie declare your functions like this
function setFirstName(){
//stuff yay!
}
Briana Swift
@brianamarie
Apr 08 2015 21:14
I changed the function declarations in the closures to this syntax and it's telling me "undefined is not a function"
var Person = function(firstAndLast) { 
  var nameArr = firstAndLast.split(' ');
  this.firstName = nameArr[0];
  this.lastName = nameArr[1];
  this.fullName = firstAndLast.toString(); 
  this.setFirst = 0;
  this.setLast = 0; 
  this.setFull = 0; 
};

(function() {
  function getFirstName(){
    return this.firstName;
   }
  function getLastName(){
    return this.lastName;
  }
  function getFullName(){
    return this.fullName;
  }
  function setFirstName(first){
    this.firstName = first;
  }
  function setLastName(last){
    this.lastName = last;
  }
  function setFullName(full){
    this.fullName = full;
  }
}).call(Person.prototype);


var bob = new Person('Bob Ross');
bob.getFullName();
Ben McMahon
@benmcmahon100
Apr 08 2015 21:15
This is more like how i solved it
var Person = function(firstAndLast) { 
  var nameArr = firstAndLast.split(' ');
  this.firstName = nameArr[0];
  this.lastName = nameArr[1];
  this.fullName = firstAndLast.toString(); 
  this.setFirst = 0;
  this.setLast = 0; 
  this.setFull = 0; 

function getFirstName(){
    return this.firstName;
   }
  function getLastName(){
    return this.lastName;
  }
  function getFullName(){
    return this.fullName;
  }
  function setFirstName(first){
    this.firstName = first;
  }
  function setLastName(last){
    this.lastName = last;
  }
  function setFullName(full){
    this.fullName = full;
  }
};

var bob = new Person('Bob Ross');
bob.getFullName();
Briana Swift
@brianamarie
Apr 08 2015 21:16
Ah. Looks to me like a big difference is that I wasn't wrapping the closure functions within the "People" function. Lemme change that within my code and see if that changes anything...
That isn't working for me either. Do the functions getFirstName, getLastName, etc need to be defined outside the scope of the Person function to be accessable?
Ben McMahon
@benmcmahon100
Apr 08 2015 21:23
sorry here
var Person = function(firstAndLast) { 
  var nameArr = firstAndLast.split(' ');

  this.getFirstName = function() {
    return nameArr[0];
  };
  this.getLastName = function() {
    return nameArr[1];
  };
  this.getFullName = function() {
    return firstAndLast; 
  }; 
  this.setFirstName = function(first){
    this.firstName = first;
  };
  this.setLastName = function(last){
    this.lastName = last;
  };
  this.setFullName = function(full){
    this.fullName = full; 
  };
};

var bob = new Person('Bob Ross');
bob.getFullName();
this works a lot better
var Person = function(firstAndLast) {

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

var bob = new Person('Bob Ross');
bob.getFullName();
Briana Swift
@brianamarie
Apr 08 2015 21:28
Ah. I see! Thank you @benmcmahon100! :clap:
Ben McMahon
@benmcmahon100
Apr 08 2015 21:33
does it work fully?
Briana Swift
@brianamarie
Apr 08 2015 21:34
Not yet...still trying to tweak it. Not sure where the problem is so I'm going back and doing some more reading on closures
Ben McMahon
@benmcmahon100
Apr 08 2015 21:37
@brianamarie sorry that i can't remember how i did it :p
Briana Swift
@brianamarie
Apr 08 2015 21:40
haha it's all good. the code I posted up top seems to be the closest to working and I am still stumped on why it is/isn't returning undefined when it shouldn't be. thank you for your help! I'll let you know if I figure it out so someone on here later might search and have the answers that I can't seem to find!
Briana Swift
@brianamarie
Apr 08 2015 21:51
Yay!!! FINALLY figured it out. Without posting the working code here, I will say I figured out the problem. Some of the tests were "firstName", which while it wasn't reachable, it did exist in the first function. When it was called, it wasn't giving "undefined" as it should have been due to its existance. When I changed the name of my placeholder firstName and lastName to FirstName and LastName (changed all instances of it so it still functioned), the code worked. 10 green checkmarks. :sparkles: