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 trialarmen bagdasarian
Courses Plus Student 234 PointsWhy make a class?
In this video, Jason created a class, within this class he created a function that puts out a string. then to be able to see that string on our console, he called the class.
my question is, what is the difference between doing this with a class and writing a function and calling the function.
1 Answer
Brian Spinos
15,722 PointsIn that example it does not make sense, but as your app grows, you will feel the need to bundle up variables and functions in one place, that is the class. You will feel even more the need to bundle variables and functions together when the code gets complex and you just want to hide some functions and variables, just like you would clean your room by throwing things in the closet to keep them βprivateβ. Another way to think about it is that all the functions and variables that you feel are related, should be in a single unit: the class