Now that we've put our user together we're gonna repeat the same process and create a second file to
represent a company inside of application as well.
So to get started inside of my s RC directory I'll make a new file called company dot t s inside of
here I'm going to once again import the faker module from faker and I'll define a new class and immediately
export it called company so let's think about what different properties we might want a company to have.
I think that maybe if we go back over to the documentation for faker one more time.
Remember we have that company section so we've got different properties in here like say company name
and we've got catchphrase and some other stuff like that as well.
So let's have every company have a company name property.
There'll be a string and a catch phrase property that will be a string as well.
In addition we'll also have a company have a location that will be a latitude and longitude that's going
to represent their physical location the world so we can eventually represent them as a marker on our
map.
OK.
So back over here we'll do a company name that has a string and then we'll do a catchphrase that is
a string we'll also do a location that is giving an object with a latitude property that is a number
and a longitude property that is a number as well.
Now one thing only mentioned here is that calling the company name company name is really not necessary.
I think a much more ideal property name here would be name like so.
But I just want to give it some differentiation from our user who had a name property as well so just
to make a little bit more stark difference between a company and a user.
I'm gonna have the company have a property of company name instead.
All right so now once again we can define our constructor function which is where we're going to initialize
all those different properties.
So I'll say this dot company name will be faker dot company dot company name.
Like so many collapses sidebars we can see that whole line
we can then do our catchphrase which will be fake or dot company dot catchphrase and then finally we
can also initialize our latitude and longitude as well.
Remember like we just discussed this right here does not initialize the location property.
It just tells typescript here's what location will be.
So if we try to assign a value directly to this dot location dot let we'll get an error message because
location is undefined inside the constructor.
So we have to initialize the location property and everything inside of it.
And one easy way to do that is to say this dot location is going to be an object with properties lat
and LNG then side of here we can once do again do a fake dot address dot latitude make sure you get
the comma at the end of the line and then faker address dot longitude as well.
And once again don't forget the parentheses.
All right we're seeing the same errors error as before we are trying to take a string because that is
what we get back from faker and assign it to a property that's supposed to be a number.
So once again we have to do a pass float
and a past float
and that's it.
All right.
So I think we're all set here.
We already got that export statement so now we can import this into our index dot t yes file create
an instance of a company really quickly and just make sure everything works as expected.
So back inside of index dot yes I will import company from company and then underneath our user I'll
say company is going to be a new company like so and I'll do a console log of that company
then as a quick test I'll flip back on my browser my library load already kicked in and I can see that
console log right here.
So I'll expand company and I'll see that I've got a really great catch phrase persistent directional
function and my company name is King group once again really should not be calling that property company
name just name would be much more appropriate because we really know that it is a company we're working
with.
However once again we want to just differentiate the company from the user which had a name property
and once again I've got a location with a latitude and longitude as well all right.
So that's pretty much it.
We've created a class to represent our user and our company.
So let's take another quick pause right here.
When we come back the next section we're gonna start working on getting a Google map to display on our
screen as well.
So I'll see you in just a minute.