Codecademy Forums

Random Question Regard Learn JavaScript Classes Area

Probably a dumb question.
https://www.codecademy.com/paths/web-development/tracks/webdev-intermediate-javascript/modules/learn-javascript-classes/lessons/classes/exercises/constructor-method

In this lesson they teach us about classes one random question that I have that I can’t get out of my mind is in their example (dog class) they have one argument (name) but there is also a property called behavior. Why would the behavior not be an argument as well? In the exercise Surgeon takes in two argument (parameters). Just wondering why not take in the behavior? Is there a reason for it or just did not.

When starting to count, you’d always start at zero.
You might want to create a dog starting at a different count, sure, but if not, then there’s no reason to pass it in on creation.

1 Like

An example that I think would be easier to make sense out of (just about every tutorial ever made on classes model something so pointless you can’t figure out what problem is solved):

If you made a class representing text (a string, essentially)

Then, it would have a length or size attribute. The class would manage this, and update it every time the text is modified. You wouldn’t tell the class how long the string is when instantiating the class.

1 Like

Thank you! Both of your comments makes sense to me.

1 Like