From the course: TypeScript: Object-Oriented Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Classes

Solution: Classes

From the course: TypeScript: Object-Oriented Programming

Start my 1-month free trial

Solution: Classes

(punchy electronic music) - [Instructor] All right, hopefully you were able to solve that, but if not, don't worry! We're going to go ahead and define a class here. We're going to call it User. Pretty straightforward at this point. We have our User class. class, keyword, User, name. Now, at this point we are going to add a property, and we'll call it firstName, and you might imagine this is going to be a string. Call it lastName, this is going to be a string as well. And then we'll have an email property, and this will also be a string. Now, our get property, we're going to call fullName, and what this is going to be expected to return is going to be our first name, and then our last name. Now if you were a little bit more formal than I am, what you might actually have done is put last name comma first name, which reminds me of my days back in school. (laughs) So last but not least, we're going to write an email.…

Contents