Welcome back, my friends.
I hope you enjoy the last class, so what are we going to do here?
I'm going to create additional function for calculating all of the patients.
So method for calculating.
The patients.
So we're going to put it inside the clinic, OK, what because this matter will be mostly used by the
clinic and it will not have any connection with the other things.
So I'm going to say Colque patients here.
This might slightly differ from what I have in the final version, but that's pretty much it.
So I'm going to say patience and I'm going to put a data here.
Right.
Or I'm just going to say, Ereira here, I don't want to confuse you here, are we going to pass past
the area of patients?
But before that, I'm just going to let here be patients that will be equal to work, equal to zero.
Good.
So I declare E and I initialized a variable to zero.
Now I'm just going to look through for each and I'm going to say element
so you can say element current, whatever it's there.
And let's create here the patients that we create the variable before.
So I want the store to loop through each and every element.
And I want the store to grab the positions while I'm doing this, you will see very soon, so I'm just
going to come out of the area.
OK, so this function will not work at the moment because first we need to go to the CLIDE reports and
we need to call it.
So first, as I told you, I need to create an area of, um, an area of patients.
So how are we going to do this?
Let's create first let so I'm not going to create I'm going to create an instance of the class.
So clinic that will be new clinic.
Good.
So this is this I'm going to use it for calling the functions so const patients.
This will be equal to clinics.
I'm using these clinics here, the area that I had before and I'm going to put the I'm going to on top
of that, I'm going to create a map mechanism.
This map method will return unary and put it here.
So in the map method, they have the access of the current element.
Right.
And I'm going to do it with every function and I'm going to say, OK, return for the current.
So it's going to look through these clinics and I want to return these patients daily patients right
now.
If I do a lot of patients, I would like to see an array with one hundred five, one hundred seventy
two, thirty three and sixty six.
Now this is in my final one.
So if I don't want to put in every.
Like that, it will give me one big area of this so even I can use this now, I'm just going to show
you the two things.
So if I have it inside of sorry, inside of an every.
So when I call now, I can use the clinic, this instance here of the clinic last night called the Issues
and I'm going to get past this patient's every right, because now we know that we have unary here.
Good.
Area of an area.
Now this is coming from inside that one inch here.
Right.
So before I do this, I'm just going to tell you, if I can, a the element why you use zero position.
You will see very shortly.
So I control the entire area here and it was working.
That's why I just put it there for testing.
Now, I don't need this one anymore, but now let's just print out the one element.
It will give me the area.
So if I try now to get through this and if I cassella the patients, that will happen, it will give
me some crazy things, because this is not how we managed to get the values of the value values actually
in the zero position.
That's why I just put it zero like this.
OK, now if you don't want to use it like this now, the patient actually will work.
It will calculate everything.
But if you don't want to use it like this, this is in my final version.
OK, so I'm going to create it like this.
And so let's create it like this one.
It's like in the final and I'm going to show you what you need to change in order to be a little bit
more easy without this zero.
Right.
OK, so a lot I don't need here to control a lot of the patient, actually.
Now you know that I'm going to look through each and every element grab these values is stored in the
patient.
That was the logic here.
OK, now I just want to consult a couple of things.
And if you don't want to waste time, that folder.
Sorry, remember that file that we put here on the where was it and why.
It's not what didn't open.
How strange is this?
OK, let's read it
actually to have that file here.
Here is.
OK.
That is strange.
Never happened before, right?
Just going to.
So, I mean, a starter folder, I'm going to open file, so it should be opening the file.
Here it is.
But this is from the desktop, maybe because it was open.
Now, just going to copy this one, copy the entire console lot from here.
It just going to close this one for now.
And I'm going back to the starter, so I don't have anything in the starter right now.
I'm going to be it here I don't want to do to write and waste time of you guys so deep Asian.
What I'm doing slash already got length and this will get the length of the actually the length of the
error is four, because what we do have, we have four clinics.
Good.
If we, if you have, if you add one more it will be five.
Now the patients total and after that what I'm doing, the patients times 50 to get the income and to
get the average income.
I'm using this.
I'm 50.
OK, so what I haven't shown you before was that in the template literals, you can use the simple map
and this is called interpolation.
So you can use the simple math functions inside here and that will not affect.
Oh OK, let's save it and let's see if that is the reality here.
Here it is.
One, two, three and four.
And I'm getting this nice.
So I'm just going to come along, I'm going to remove this, and now everything should be normal.
Good.
We have one, two, three, four, all done.
So that is the old way.
I mean, the original I'm going to see here, original as it is in the final file.
OK, I'm going to create something else.
I'm going to say corporations.
I'm going to use the same one and I'm going to get modified.
Now, this will do as Jacklin is this.
But I'm going to change here.
I'm just going to pass in the element.
But here I need to fix some things.
Remember, here we just storing everything in the patients as an array of areas.
But what we can do is actually modify.
Let me just copy this to.
And some say a modified version, and it will be exactly the same thing.
So I'm just going to comment this one right in here.
I'm going to pass and not as an area, just one on one big area.
And what that will do, it will give me not applicable.
Let's see.
Why is this happening?
OK, let's go back first.
I'm going to cancel that, OK?
Yeah.
Because I don't I don't access the same function.
And I'm going to say here, what was the name Modify.
Right.
Because I'm trying to do X is the same function as before.
Maybe you got this one.
If you did Bravo
and now you work here is the same thing, but it's easier you don't think of each element of the position
you need to grab.
Now, this is easier.
So I'm going to leave the modified version, so you're going to have this one is going to be different
from the final, but this will be in the final.
You know, you have different different starter.
And when you when we finish this one, it will be a little bit different.
OK, now, what else we need to do here?
Go back to the report.
We need to do five, six, seven and eight.
That's a newly opened a dental clinic, two thousand sixty two thousand twenty, the smallest and the
largest number of patients.
How are we going to do this?
OK, let's think a little bit.
First right here, clinic sighs You know what else we need here to do, we need to grab the newly opened
a dental clinic and we're going to use this structuring for this.
But first, let's create a constant called year details, and I'm going to store all the years for each
and every clinic.
So how are we going to do this?
I'm going to access the clinics.
I'm going to use the same same here
map.
And I'm going to say current.
And I want Kuranda to access the year of Bill.
So look what I'm doing, I'm doing I'm seeing as a patients, I'm storing this here.
So if I do cause a lot of years of build.
Here are details I will have a list of years in one area, not as a separate area, just in one area,
as I did here with the patients.
Good.
Now, what I need to do is actually I need to use this area here, the newly created from the map function,
and I need to create a function, get min max and I need to pass in this year details.
So actually it becomes a lot.
This entire function, but look what is happening here.
I don't actually call with the clinic, so my idea is to use this function outside, I'm not going to
create it inside the clinic.
And the reason why, because the same function can be reused even for the plaques, which I'm not going
to do.
But that will be your homework.
Right.
But you will see.
So here I'm seeing function Bemax.
Right.
And what we need for this function is to pass the data cool.
In here.
We're going to use the spread operator.
So if you're confused, how are we going to use the spread of freedom?
It's going to be really simple.
Let me just write it down.
So math doesn't mean you're going to use this mean method here.
I'm going to use the spread operator and cost Max left that Max, and I'm going to say three that data.
OK, I'm going to return an error rate of me and comma Max.
So let me explain what this is doing.
So the spread operator, I do have how many years I do have to actually it's giving me the result back.
I had four years here.
And what this will do, it will create a four different variables in this neat map that mean method
that I haven't shown you before.
It will go through all of these variables, all of these data, and it will find the minimum value is
store it in this constant.
Same goes for Max.
It will go through four of the variables, find the biggest one is stored in the max.
And I'm just returning it now.
How I told you that we're going to do this now.
I'm going we are going to use the structure.
So why the structure?
Because it's going to be easy to see here.
Right.
So I'm going to create a constant here with two values in the first, I'm going to see new built
and all built, right.
So you can create any variable you want, but put it all built in after that.
I'm going to grab the result from this function so I don't need this console anymore.
So how was this structuring was working?
So here these two variables are going to grab the result from these two and actually for this function
and this function will return to Herry values.
Right.
So that every so the destructing was working with areas, with objects.
So that's why I use it here.
And you can use the structure.
Now, what we need to do is to see Conjola.
So we're going to use number five and we see the newly open dental.
Come on, dental clinic was opened in the year, and I'm going to access new build like that and I'm
going to copy this one and I'm going to put it one more and I'm going to see six.
And here should not be the newly opened.
It will be the oldest, the oldest dental clinic or the newest dental clinic that's open.
The oldest in the league was open in a year.
And we need to change this or build hope.
This is going to work and it's 20, 20 in 2016.
So how we grab these values, we're grabbing from here to 2016.
Two thousand.
OK, let's put here let's change this.
Twenty twenty.
Make it twenty two thousand.
Right.
So the maximum will be the newest will be twenty nineteen and this one will be right.
Where was it.
Here is number five and six.
So the newest was open it in two thousand and the oldest was open it in two thousand ninety.
Cool.
I'm just going to change it back to twenty twenty five.
You can put any years you want there.
Now one more thing is that we can we use the same function.
I'm just going to copy it
and I'm going to put it here and I'm going to say min
max and plus I need to grab this.
So even here you should go there.
Now, tips for finding the smallest number of patients.
We need to grab the patients.
Right.
So instead of this current that you're built, I'm going to see daily patients and I'm going to change
here to clinic patients.
Nice going to pass the same one so I can reuse the function, I'm going to grab the main max and I'm
just going to change here the mean Max and here she be, the smallest number number of patients in one
day was, OK, I'm just going to copy and this is actually not five and six is seven.
Sorry.
And eight.
And this should be the opposite, the largest no good and here is the smallest is thirty three and the
largest is one seventy two.
How this is working, we use the same function.
OK, go back here.
One, two, five one seventy two, thirty three and sixty six.
So this is the smallest number of patient Docklands and the largest is having the Brighton Coupe.
So we are finished.
Actually this is identical to what we have in our report a little bit, maybe change of the wording,
but that is pretty much it.
We are done now.
We need to do the parking report and that's it.
We will do that in the next lecture.
I hope you enjoyed this one.
And I will be not angry because we got a little bit from we cheat a little bit copy from the final final
at the gas file because I want to speed up things.
And yes, that's pretty much it.
I don't want to waste your time.
So see you in the next one.