Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Making the UI Work

I got several different questions.

Hello, these are my questions:

  • What is the difference between += ++, -= --
  • How (this.example = example) works, I can't understand it very well.
  • After I finish the full stack Js course will I be able to write programs correctly or do I need to do anything further.
  • Should I be doing projects while doing the course or after it?
  • What does the following code does? I am more confused with the second code block and what it does, If you could clear this up for me it would be awesome :)
  • What is the difference between .push, .append, .add methods.
  • When do I know that I need to add parenthesis around something, for example, how do I recognize that I need to add parenthesis around .add() or .push()
  • Difference between calling a function the traditional way example() and call()
function Monster(rank) {
  this.rank = rank;
  this.health = 100;
}

Monster.prototype.takeHit = function() {
  this.health--;
}

I know that these are allot of questions but these are more like missing pieces of a puzzle for me. Thank you very much for taking the time and effort to help me. Stavros

1 Answer

Steven Parker
Steven Parker
231,275 Points

Wow what a collection, I'll give them a shot:

  • What is the difference between += ++, -= --

Well, "+=" adds and assigns at the same time, you need something on both sides for it to work. But "++" adds one just by itself, and you use it with just one thing. So for example, these two lines do the same thing, they both make count bigger by 1:

count += 1;
count++;

And "-=" and "--" are the same kinds of things except they subtract instead of add.

  • How (this.example = example) works, I can't understand it very well.

Basically, this would take the value from a normal variable named example and put it into a property of the current object that also has the name example. But it's impossible to know what the "current object" might be without seeing more of the code near where this line of code would be found.

  • After I finish the full stack Js course will I be able to write programs correctly or do I need to do anything further.

It depends on how well you've converted the knowledge into skill. There's enough knowledge in the track, but your ability to to apply that knowledge will make the difference.

  • Should I be doing projects while doing the course or after it?

That depends on your learning style. Some people find it helps to reinforce what they are learning, others find it a distraction and get more from taking the course to completion before doing things with it.

  • What does the following code does? I am more confused with the second code block and what it does, If you could - clear this up for me it would be awesome :)

The Monster object is being given a method named takeHit. When it is called, this method will reduce the value of the health property of the monster by 1.

  • What is the difference between .push, .append, .add methods.

It depends on what things these are methods of. But commonly, push is a method of an array, and it adds a new item to the end of the array. append is often a jQuery object method that adds a new HTML element to the one represented by the jQuery object it is applied to. add is perhaps the most ambiguous of these, without seeing how it is used it could be adding to a set, or a class list, or an HTML element.

  • When do I know that I need to add parenthesis around something, for example, how do I recognize that I need to add parenthesis around .add() or .push()

Do you mean after a method name? They are always required to invoke ("call") the method, whether or not they surround any arguments. You only leave them off when you want to refer to the function instead of calling it (such as when you pass the name as a callback to another function).

  • Difference between calling a function the traditional way example() and call()

I don't see any difference here, other than the names. These both look like examples of calling functions.

Whew! :relieved: I sure hope that helps!

Thank you very much Steven I think I am going to finish the course first and after I will be doing some projects, I would like to ask something else, it might sound stupid but how many hours studying on treehouse are good for someone determined to become an expert on what he want's to do per day and it is a hobby? I don't have a fixed timetable or something, whenever I am free from any chores and college I sit down and read even inside the college but I feel that sometimes the quality of studying varies, sometimes I might be more concentrated and others I might go on a kind of relax mode which I believe I absorb less than I am supposed to, if you had this experience could you tell me how to take my reading skills to the top, because having allot of time and working less "efficient" doesn't get you towards where you want to go. If I work hard how many months will it take me to learn 5 programming languages? estimated always Aw something else since I believe you are older than me you might have experience on this, my college is horrible, we are "learning" a year now on how to use word and excel, from that alone you can understand the education level I am receiving in college and it feels more like a waste of energy and time. What do you believe is best to do, I feel very frustrated by the fact that I waste allot of hours in there and sometimes I just want to leave college for good and not come back. Any tips you might want to share to bypass these "kinds" of situations? I just want to let you know that I appreciate your effort and time on any of my questions that you answer. Again thank you very much. Stavros

Steven Parker
Steven Parker
231,275 Points

I don't have any guides on how many hours to study. I do know that the amount of time each student spends is very personal, and varies widely.

I also know that not every college is good for every student. You must pick a college that is a good "fit" for you. If your college does not provide the type or level of learning you seek you may need to find a different one.

Ok, thank you.

I will do it Steven :) but I want to see if other people might want to give their personal experiences on the specific subject.