Why 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
Brian Spinos
8,907 Points

In 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