1 00:00:02,250 --> 00:00:03,150 Welcome back, my friends. 2 00:00:03,170 --> 00:00:06,180 I hope you enjoy the last class, so what are we going to do here? 3 00:00:06,870 --> 00:00:11,820 I'm going to create additional function for calculating all of the patients. 4 00:00:12,030 --> 00:00:14,790 So method for calculating. 5 00:00:17,030 --> 00:00:17,810 The patients. 6 00:00:19,820 --> 00:00:24,740 So we're going to put it inside the clinic, OK, what because this matter will be mostly used by the 7 00:00:24,740 --> 00:00:28,520 clinic and it will not have any connection with the other things. 8 00:00:28,670 --> 00:00:30,590 So I'm going to say Colque patients here. 9 00:00:33,320 --> 00:00:37,860 This might slightly differ from what I have in the final version, but that's pretty much it. 10 00:00:38,360 --> 00:00:42,590 So I'm going to say patience and I'm going to put a data here. 11 00:00:43,790 --> 00:00:44,210 Right. 12 00:00:47,480 --> 00:00:53,390 Or I'm just going to say, Ereira here, I don't want to confuse you here, are we going to pass past 13 00:00:53,390 --> 00:00:56,030 the area of patients? 14 00:00:56,180 --> 00:01:04,010 But before that, I'm just going to let here be patients that will be equal to work, equal to zero. 15 00:01:04,430 --> 00:01:04,780 Good. 16 00:01:05,180 --> 00:01:10,820 So I declare E and I initialized a variable to zero. 17 00:01:11,120 --> 00:01:16,280 Now I'm just going to look through for each and I'm going to say element 18 00:01:19,280 --> 00:01:22,250 so you can say element current, whatever it's there. 19 00:01:22,490 --> 00:01:28,940 And let's create here the patients that we create the variable before. 20 00:01:29,090 --> 00:01:32,360 So I want the store to loop through each and every element. 21 00:01:35,330 --> 00:01:43,370 And I want the store to grab the positions while I'm doing this, you will see very soon, so I'm just 22 00:01:43,370 --> 00:01:46,590 going to come out of the area. 23 00:01:46,880 --> 00:01:54,230 OK, so this function will not work at the moment because first we need to go to the CLIDE reports and 24 00:01:54,230 --> 00:01:55,130 we need to call it. 25 00:01:55,280 --> 00:02:02,020 So first, as I told you, I need to create an area of, um, an area of patients. 26 00:02:02,180 --> 00:02:03,220 So how are we going to do this? 27 00:02:03,830 --> 00:02:10,140 Let's create first let so I'm not going to create I'm going to create an instance of the class. 28 00:02:10,200 --> 00:02:13,580 So clinic that will be new clinic. 29 00:02:14,220 --> 00:02:14,570 Good. 30 00:02:15,380 --> 00:02:22,010 So this is this I'm going to use it for calling the functions so const patients. 31 00:02:23,720 --> 00:02:25,610 This will be equal to clinics. 32 00:02:26,180 --> 00:02:32,780 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 33 00:02:32,780 --> 00:02:34,520 of that, I'm going to create a map mechanism. 34 00:02:34,520 --> 00:02:37,580 This map method will return unary and put it here. 35 00:02:37,760 --> 00:02:40,640 So in the map method, they have the access of the current element. 36 00:02:40,640 --> 00:02:40,960 Right. 37 00:02:41,320 --> 00:02:46,680 And I'm going to do it with every function and I'm going to say, OK, return for the current. 38 00:02:46,700 --> 00:02:54,410 So it's going to look through these clinics and I want to return these patients daily patients right 39 00:02:55,280 --> 00:02:55,550 now. 40 00:02:55,550 --> 00:03:05,390 If I do a lot of patients, I would like to see an array with one hundred five, one hundred seventy 41 00:03:05,390 --> 00:03:08,150 two, thirty three and sixty six. 42 00:03:09,330 --> 00:03:11,060 Now this is in my final one. 43 00:03:11,300 --> 00:03:13,250 So if I don't want to put in every. 44 00:03:15,510 --> 00:03:22,410 Like that, it will give me one big area of this so even I can use this now, I'm just going to show 45 00:03:22,410 --> 00:03:23,290 you the two things. 46 00:03:23,850 --> 00:03:27,690 So if I have it inside of sorry, inside of an every. 47 00:03:29,940 --> 00:03:38,340 So when I call now, I can use the clinic, this instance here of the clinic last night called the Issues 48 00:03:38,520 --> 00:03:46,510 and I'm going to get past this patient's every right, because now we know that we have unary here. 49 00:03:47,010 --> 00:03:47,400 Good. 50 00:03:49,210 --> 00:03:50,410 Area of an area. 51 00:03:50,450 --> 00:03:57,490 Now this is coming from inside that one inch here. 52 00:03:58,870 --> 00:03:59,240 Right. 53 00:03:59,530 --> 00:04:10,170 So before I do this, I'm just going to tell you, if I can, a the element why you use zero position. 54 00:04:10,300 --> 00:04:11,950 You will see very shortly. 55 00:04:12,220 --> 00:04:16,620 So I control the entire area here and it was working. 56 00:04:16,630 --> 00:04:18,290 That's why I just put it there for testing. 57 00:04:18,530 --> 00:04:23,470 Now, I don't need this one anymore, but now let's just print out the one element. 58 00:04:23,470 --> 00:04:25,110 It will give me the area. 59 00:04:25,360 --> 00:04:41,770 So if I try now to get through this and if I cassella the patients, that will happen, it will give 60 00:04:41,770 --> 00:04:49,150 me some crazy things, because this is not how we managed to get the values of the value values actually 61 00:04:49,150 --> 00:04:50,870 in the zero position. 62 00:04:50,890 --> 00:04:53,140 That's why I just put it zero like this. 63 00:04:53,420 --> 00:04:58,510 OK, now if you don't want to use it like this now, the patient actually will work. 64 00:04:58,990 --> 00:05:00,220 It will calculate everything. 65 00:05:00,430 --> 00:05:03,730 But if you don't want to use it like this, this is in my final version. 66 00:05:04,210 --> 00:05:06,370 OK, so I'm going to create it like this. 67 00:05:07,450 --> 00:05:10,600 And so let's create it like this one. 68 00:05:10,600 --> 00:05:15,430 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 69 00:05:15,430 --> 00:05:17,130 more easy without this zero. 70 00:05:17,140 --> 00:05:17,440 Right. 71 00:05:17,650 --> 00:05:22,560 OK, so a lot I don't need here to control a lot of the patient, actually. 72 00:05:22,810 --> 00:05:27,760 Now you know that I'm going to look through each and every element grab these values is stored in the 73 00:05:27,760 --> 00:05:28,170 patient. 74 00:05:28,180 --> 00:05:29,390 That was the logic here. 75 00:05:29,860 --> 00:05:32,890 OK, now I just want to consult a couple of things. 76 00:05:33,580 --> 00:05:38,170 And if you don't want to waste time, that folder. 77 00:05:38,170 --> 00:05:45,470 Sorry, remember that file that we put here on the where was it and why. 78 00:05:45,470 --> 00:05:46,630 It's not what didn't open. 79 00:05:49,960 --> 00:05:51,050 How strange is this? 80 00:05:51,540 --> 00:05:54,340 OK, let's read it 81 00:05:57,430 --> 00:05:58,810 actually to have that file here. 82 00:05:58,840 --> 00:05:59,320 Here is. 83 00:06:02,460 --> 00:06:03,200 OK. 84 00:06:05,120 --> 00:06:06,020 That is strange. 85 00:06:06,110 --> 00:06:07,560 Never happened before, right? 86 00:06:08,120 --> 00:06:08,640 Just going to. 87 00:06:09,590 --> 00:06:15,860 So, I mean, a starter folder, I'm going to open file, so it should be opening the file. 88 00:06:15,890 --> 00:06:16,400 Here it is. 89 00:06:16,970 --> 00:06:19,620 But this is from the desktop, maybe because it was open. 90 00:06:19,910 --> 00:06:23,860 Now, just going to copy this one, copy the entire console lot from here. 91 00:06:24,830 --> 00:06:27,680 It just going to close this one for now. 92 00:06:27,950 --> 00:06:33,730 And I'm going back to the starter, so I don't have anything in the starter right now. 93 00:06:33,830 --> 00:06:39,680 I'm going to be it here I don't want to do to write and waste time of you guys so deep Asian. 94 00:06:39,920 --> 00:06:46,300 What I'm doing slash already got length and this will get the length of the actually the length of the 95 00:06:46,310 --> 00:06:50,930 error is four, because what we do have, we have four clinics. 96 00:06:51,110 --> 00:06:51,440 Good. 97 00:06:51,590 --> 00:06:54,630 If we, if you have, if you add one more it will be five. 98 00:06:54,950 --> 00:07:02,770 Now the patients total and after that what I'm doing, the patients times 50 to get the income and to 99 00:07:02,780 --> 00:07:03,800 get the average income. 100 00:07:03,800 --> 00:07:04,820 I'm using this. 101 00:07:06,290 --> 00:07:06,990 I'm 50. 102 00:07:07,080 --> 00:07:13,940 OK, so what I haven't shown you before was that in the template literals, you can use the simple map 103 00:07:14,570 --> 00:07:17,000 and this is called interpolation. 104 00:07:17,120 --> 00:07:21,380 So you can use the simple math functions inside here and that will not affect. 105 00:07:21,650 --> 00:07:27,470 Oh OK, let's save it and let's see if that is the reality here. 106 00:07:27,670 --> 00:07:28,210 Here it is. 107 00:07:28,370 --> 00:07:29,570 One, two, three and four. 108 00:07:29,900 --> 00:07:32,030 And I'm getting this nice. 109 00:07:34,590 --> 00:07:39,950 So I'm just going to come along, I'm going to remove this, and now everything should be normal. 110 00:07:40,170 --> 00:07:40,480 Good. 111 00:07:40,560 --> 00:07:42,630 We have one, two, three, four, all done. 112 00:07:42,930 --> 00:07:46,150 So that is the old way. 113 00:07:46,230 --> 00:07:56,340 I mean, the original I'm going to see here, original as it is in the final file. 114 00:07:56,710 --> 00:07:58,760 OK, I'm going to create something else. 115 00:07:59,160 --> 00:08:00,920 I'm going to say corporations. 116 00:08:00,930 --> 00:08:04,490 I'm going to use the same one and I'm going to get modified. 117 00:08:06,510 --> 00:08:10,800 Now, this will do as Jacklin is this. 118 00:08:10,800 --> 00:08:12,060 But I'm going to change here. 119 00:08:13,140 --> 00:08:15,390 I'm just going to pass in the element. 120 00:08:16,170 --> 00:08:18,030 But here I need to fix some things. 121 00:08:19,200 --> 00:08:24,930 Remember, here we just storing everything in the patients as an array of areas. 122 00:08:25,050 --> 00:08:30,270 But what we can do is actually modify. 123 00:08:32,730 --> 00:08:34,710 Let me just copy this to. 124 00:08:37,330 --> 00:08:45,440 And some say a modified version, and it will be exactly the same thing. 125 00:08:46,690 --> 00:08:50,410 So I'm just going to comment this one right in here. 126 00:08:50,410 --> 00:08:55,660 I'm going to pass and not as an area, just one on one big area. 127 00:08:56,380 --> 00:09:02,460 And what that will do, it will give me not applicable. 128 00:09:02,470 --> 00:09:02,920 Let's see. 129 00:09:02,920 --> 00:09:04,270 Why is this happening? 130 00:09:04,690 --> 00:09:07,830 OK, let's go back first. 131 00:09:07,960 --> 00:09:09,120 I'm going to cancel that, OK? 132 00:09:09,130 --> 00:09:09,400 Yeah. 133 00:09:09,850 --> 00:09:12,300 Because I don't I don't access the same function. 134 00:09:12,310 --> 00:09:15,430 And I'm going to say here, what was the name Modify. 135 00:09:15,560 --> 00:09:15,910 Right. 136 00:09:16,090 --> 00:09:19,000 Because I'm trying to do X is the same function as before. 137 00:09:19,180 --> 00:09:20,260 Maybe you got this one. 138 00:09:20,380 --> 00:09:21,820 If you did Bravo 139 00:09:24,310 --> 00:09:32,950 and now you work here is the same thing, but it's easier you don't think of each element of the position 140 00:09:32,950 --> 00:09:33,640 you need to grab. 141 00:09:33,820 --> 00:09:35,440 Now, this is easier. 142 00:09:40,440 --> 00:09:44,790 So I'm going to leave the modified version, so you're going to have this one is going to be different 143 00:09:44,790 --> 00:09:47,670 from the final, but this will be in the final. 144 00:09:47,760 --> 00:09:51,110 You know, you have different different starter. 145 00:09:51,360 --> 00:09:54,480 And when you when we finish this one, it will be a little bit different. 146 00:09:54,510 --> 00:09:56,480 OK, now, what else we need to do here? 147 00:09:57,300 --> 00:09:58,670 Go back to the report. 148 00:09:59,820 --> 00:10:02,190 We need to do five, six, seven and eight. 149 00:10:02,190 --> 00:10:08,430 That's a newly opened a dental clinic, two thousand sixty two thousand twenty, the smallest and the 150 00:10:08,430 --> 00:10:09,680 largest number of patients. 151 00:10:10,440 --> 00:10:11,490 How are we going to do this? 152 00:10:11,880 --> 00:10:14,370 OK, let's think a little bit. 153 00:10:16,590 --> 00:10:26,040 First right here, clinic sighs You know what else we need here to do, we need to grab the newly opened 154 00:10:26,040 --> 00:10:29,600 a dental clinic and we're going to use this structuring for this. 155 00:10:30,060 --> 00:10:39,960 But first, let's create a constant called year details, and I'm going to store all the years for each 156 00:10:39,960 --> 00:10:40,720 and every clinic. 157 00:10:40,740 --> 00:10:41,700 So how are we going to do this? 158 00:10:41,820 --> 00:10:42,960 I'm going to access the clinics. 159 00:10:42,960 --> 00:10:44,910 I'm going to use the same same here 160 00:10:47,850 --> 00:10:48,390 map. 161 00:10:49,350 --> 00:10:51,420 And I'm going to say current. 162 00:10:54,120 --> 00:10:57,240 And I want Kuranda to access the year of Bill. 163 00:10:58,080 --> 00:11:02,390 So look what I'm doing, I'm doing I'm seeing as a patients, I'm storing this here. 164 00:11:02,400 --> 00:11:05,370 So if I do cause a lot of years of build. 165 00:11:08,610 --> 00:11:15,860 Here are details I will have a list of years in one area, not as a separate area, just in one area, 166 00:11:16,310 --> 00:11:18,630 as I did here with the patients. 167 00:11:18,830 --> 00:11:19,140 Good. 168 00:11:20,010 --> 00:11:26,990 Now, what I need to do is actually I need to use this area here, the newly created from the map function, 169 00:11:28,220 --> 00:11:38,030 and I need to create a function, get min max and I need to pass in this year details. 170 00:11:38,250 --> 00:11:40,490 So actually it becomes a lot. 171 00:11:43,510 --> 00:11:46,490 This entire function, but look what is happening here. 172 00:11:46,750 --> 00:11:54,400 I don't actually call with the clinic, so my idea is to use this function outside, I'm not going to 173 00:11:54,400 --> 00:11:56,120 create it inside the clinic. 174 00:11:56,440 --> 00:12:03,910 And the reason why, because the same function can be reused even for the plaques, which I'm not going 175 00:12:03,910 --> 00:12:04,180 to do. 176 00:12:04,180 --> 00:12:05,340 But that will be your homework. 177 00:12:05,620 --> 00:12:06,060 Right. 178 00:12:06,910 --> 00:12:08,250 But you will see. 179 00:12:08,800 --> 00:12:13,330 So here I'm seeing function Bemax. 180 00:12:13,720 --> 00:12:14,100 Right. 181 00:12:14,110 --> 00:12:19,000 And what we need for this function is to pass the data cool. 182 00:12:19,750 --> 00:12:20,250 In here. 183 00:12:20,260 --> 00:12:21,790 We're going to use the spread operator. 184 00:12:25,920 --> 00:12:28,220 So if you're confused, how are we going to use the spread of freedom? 185 00:12:28,420 --> 00:12:30,690 It's going to be really simple. 186 00:12:30,690 --> 00:12:31,850 Let me just write it down. 187 00:12:32,160 --> 00:12:36,230 So math doesn't mean you're going to use this mean method here. 188 00:12:36,240 --> 00:12:47,180 I'm going to use the spread operator and cost Max left that Max, and I'm going to say three that data. 189 00:12:47,850 --> 00:12:53,400 OK, I'm going to return an error rate of me and comma Max. 190 00:12:54,390 --> 00:12:56,000 So let me explain what this is doing. 191 00:12:56,190 --> 00:13:03,210 So the spread operator, I do have how many years I do have to actually it's giving me the result back. 192 00:13:03,480 --> 00:13:05,130 I had four years here. 193 00:13:05,760 --> 00:13:11,940 And what this will do, it will create a four different variables in this neat map that mean method 194 00:13:11,940 --> 00:13:13,290 that I haven't shown you before. 195 00:13:13,440 --> 00:13:18,630 It will go through all of these variables, all of these data, and it will find the minimum value is 196 00:13:18,630 --> 00:13:19,950 store it in this constant. 197 00:13:20,280 --> 00:13:21,600 Same goes for Max. 198 00:13:21,810 --> 00:13:27,270 It will go through four of the variables, find the biggest one is stored in the max. 199 00:13:27,420 --> 00:13:29,740 And I'm just returning it now. 200 00:13:29,740 --> 00:13:33,270 How I told you that we're going to do this now. 201 00:13:33,270 --> 00:13:35,370 I'm going we are going to use the structure. 202 00:13:35,650 --> 00:13:37,430 So why the structure? 203 00:13:37,530 --> 00:13:40,350 Because it's going to be easy to see here. 204 00:13:46,460 --> 00:13:46,830 Right. 205 00:13:47,120 --> 00:13:52,910 So I'm going to create a constant here with two values in the first, I'm going to see new built 206 00:13:55,430 --> 00:13:57,970 and all built, right. 207 00:13:58,280 --> 00:14:05,480 So you can create any variable you want, but put it all built in after that. 208 00:14:07,220 --> 00:14:12,050 I'm going to grab the result from this function so I don't need this console anymore. 209 00:14:12,290 --> 00:14:14,050 So how was this structuring was working? 210 00:14:14,300 --> 00:14:22,430 So here these two variables are going to grab the result from these two and actually for this function 211 00:14:22,430 --> 00:14:27,980 and this function will return to Herry values. 212 00:14:27,980 --> 00:14:28,300 Right. 213 00:14:28,430 --> 00:14:32,750 So that every so the destructing was working with areas, with objects. 214 00:14:32,900 --> 00:14:34,490 So that's why I use it here. 215 00:14:34,900 --> 00:14:36,910 And you can use the structure. 216 00:14:36,950 --> 00:14:40,580 Now, what we need to do is to see Conjola. 217 00:14:43,040 --> 00:14:52,550 So we're going to use number five and we see the newly open dental. 218 00:14:55,010 --> 00:15:08,810 Come on, dental clinic was opened in the year, and I'm going to access new build like that and I'm 219 00:15:08,810 --> 00:15:14,870 going to copy this one and I'm going to put it one more and I'm going to see six. 220 00:15:15,380 --> 00:15:18,380 And here should not be the newly opened. 221 00:15:18,430 --> 00:15:30,470 It will be the oldest, the oldest dental clinic or the newest dental clinic that's open. 222 00:15:30,620 --> 00:15:32,750 The oldest in the league was open in a year. 223 00:15:32,750 --> 00:15:35,780 And we need to change this or build hope. 224 00:15:35,780 --> 00:15:40,130 This is going to work and it's 20, 20 in 2016. 225 00:15:40,140 --> 00:15:44,000 So how we grab these values, we're grabbing from here to 2016. 226 00:15:44,000 --> 00:15:44,620 Two thousand. 227 00:15:44,630 --> 00:15:47,840 OK, let's put here let's change this. 228 00:15:47,840 --> 00:15:48,410 Twenty twenty. 229 00:15:48,620 --> 00:15:50,450 Make it twenty two thousand. 230 00:15:52,190 --> 00:15:52,640 Right. 231 00:15:52,640 --> 00:15:58,670 So the maximum will be the newest will be twenty nineteen and this one will be right. 232 00:16:00,740 --> 00:16:01,330 Where was it. 233 00:16:03,110 --> 00:16:04,420 Here is number five and six. 234 00:16:05,180 --> 00:16:10,570 So the newest was open it in two thousand and the oldest was open it in two thousand ninety. 235 00:16:10,610 --> 00:16:11,060 Cool. 236 00:16:11,930 --> 00:16:15,600 I'm just going to change it back to twenty twenty five. 237 00:16:15,710 --> 00:16:17,180 You can put any years you want there. 238 00:16:17,390 --> 00:16:21,710 Now one more thing is that we can we use the same function. 239 00:16:21,710 --> 00:16:22,640 I'm just going to copy it 240 00:16:25,610 --> 00:16:28,310 and I'm going to put it here and I'm going to say min 241 00:16:30,800 --> 00:16:34,400 max and plus I need to grab this. 242 00:16:34,560 --> 00:16:36,920 So even here you should go there. 243 00:16:37,820 --> 00:16:43,190 Now, tips for finding the smallest number of patients. 244 00:16:43,670 --> 00:16:46,730 We need to grab the patients. 245 00:16:46,730 --> 00:16:47,030 Right. 246 00:16:47,210 --> 00:16:53,510 So instead of this current that you're built, I'm going to see daily patients and I'm going to change 247 00:16:53,510 --> 00:16:55,910 here to clinic patients. 248 00:16:59,910 --> 00:17:07,110 Nice going to pass the same one so I can reuse the function, I'm going to grab the main max and I'm 249 00:17:07,110 --> 00:17:18,930 just going to change here the mean Max and here she be, the smallest number number of patients in one 250 00:17:19,560 --> 00:17:27,960 day was, OK, I'm just going to copy and this is actually not five and six is seven. 251 00:17:28,080 --> 00:17:28,580 Sorry. 252 00:17:28,590 --> 00:17:29,010 And eight. 253 00:17:31,400 --> 00:17:42,770 And this should be the opposite, the largest no good and here is the smallest is thirty three and the 254 00:17:42,770 --> 00:17:44,180 largest is one seventy two. 255 00:17:44,330 --> 00:17:46,880 How this is working, we use the same function. 256 00:17:47,270 --> 00:17:50,840 OK, go back here. 257 00:17:51,410 --> 00:17:55,340 One, two, five one seventy two, thirty three and sixty six. 258 00:17:55,430 --> 00:18:00,980 So this is the smallest number of patient Docklands and the largest is having the Brighton Coupe. 259 00:18:01,160 --> 00:18:02,900 So we are finished. 260 00:18:02,900 --> 00:18:08,030 Actually this is identical to what we have in our report a little bit, maybe change of the wording, 261 00:18:08,390 --> 00:18:10,730 but that is pretty much it. 262 00:18:11,060 --> 00:18:12,500 We are done now. 263 00:18:12,500 --> 00:18:15,500 We need to do the parking report and that's it. 264 00:18:15,500 --> 00:18:17,130 We will do that in the next lecture. 265 00:18:17,130 --> 00:18:18,170 I hope you enjoyed this one. 266 00:18:18,530 --> 00:18:27,530 And I will be not angry because we got a little bit from we cheat a little bit copy from the final final 267 00:18:27,800 --> 00:18:30,440 at the gas file because I want to speed up things. 268 00:18:30,800 --> 00:18:32,450 And yes, that's pretty much it. 269 00:18:32,450 --> 00:18:33,500 I don't want to waste your time. 270 00:18:33,650 --> 00:18:34,760 So see you in the next one.