First of all, here is a link to CodePen with some code.
It includes the test cases in this project set up as functions for testing.
I will be referring to it in the forum post content. It should be pretty easy to figure out for anyone who has reached the “Make a Person project” on Free Code Camp.
You can close the CSS window in Code Pen from the start.
You can probably close the HTML code list window after reading it.
Note: The code in the solution in CodePen is not mine. I found it online. It works. It solves the project. I am NOT going to use it to for my list of projects.
I am using it as an example to try to figure out how things work and to try to understand what the project is trying to teach so I can write my own solution.
I did write a couple of pages of code with some solutions to some of the test cases. But, I couldn’t get all of them to work. Then, I found the solution code online and figured that I should post something to the forums to try to get some direction. (Yeah - I don’t have those other solutions that I wrote. But, I was getting the first and last names from the input and putting it into an array, then getting the 0 and 1 indexes, etc. I just couldn’t get everything to work.)
I am at a point where I am really stumped about getting the whole solution to all the test cases. And, I don’t even know where to start asking questions. So, I figured I’d throw up all of this in a forum post to get some help about how to better understand the concepts behind this project.
I understand how to use a constructor to create multiple objects with the same object properties, object methods and functions by going through the MDN pages like this one to create Car objects:
There is a section on this web page for adding methods to an object. But, it seems to be a bit different from what is going on in the “Make a Person” project…or else, I am not seeing the connection.
I read the pages linked in the Hints for “Closures” and “Details of the Object Model”. But, they didn’t give me much to go on for this project which is why I am posting this. I feel like I need another MDN page to bridge between the Working with Objects MDN page that I linked above, and these two MDN pages in the hints. I feel like I understand a lot of it. I just don’t see how it connects to the “Make a Person” project. Are there other websites or other pages on MDN that I can try reading to understand this project’s goals?
I have completed all the Free Code Camp projects up to this point in order. Are there projects I could look at again before doing this one so I could get a better starting point for this one?
Here are some specific questions I have about the code solution in Code Pen. Maybe they will help give some idea about what I am confused about and what I need to learn/read up on/practice:
See the Code Pen code:
Why do bob04 and bob05 in my CodePen code return undefined? Didn’t the code just after “/***** functions for testing *****/” create a new Person object named “bob” with a first and last name when the page is loaded?
I don’t understand what is going on. The functions bob06 and bob07 return the first and last name.
I do understand what is going on in the second set of functions from bob09 onward about setting new values.
Note: There didn’t seem to be a Wiki page for this.