1 00:00:01,360 --> 00:00:02,240 Welcome, everyone. 2 00:00:02,260 --> 00:00:10,270 In today's lecture, what we are trying to do is we're going to calculate the calories that we are inserting 3 00:00:10,270 --> 00:00:14,260 into our application from user and right. 4 00:00:14,650 --> 00:00:19,780 So so far, we haven't done this and it's going to be completely new. 5 00:00:19,790 --> 00:00:26,230 We're going to use some functions, but we're not going to probably manage to display them here back 6 00:00:26,710 --> 00:00:29,790 in the front app. 7 00:00:29,860 --> 00:00:36,660 But we will try to implement those functions here today. 8 00:00:36,670 --> 00:00:42,970 So in our mean app controller, we do have this function function for adding the calories. 9 00:00:43,450 --> 00:00:47,980 So I'm going to create additional function for that will hold. 10 00:00:48,400 --> 00:00:50,320 So I'm not going to put it here. 11 00:00:50,590 --> 00:00:51,030 Right. 12 00:00:51,200 --> 00:00:57,160 I'm not going to put it in this body here, but I can do additional functions for calculating the calories 13 00:00:57,370 --> 00:00:58,680 in this here. 14 00:00:59,350 --> 00:01:00,160 This function. 15 00:01:00,160 --> 00:01:01,690 Just let me calculate. 16 00:01:05,150 --> 00:01:11,690 So now maybe you're a little bit confused and you say, OK, now why don't you write this function when 17 00:01:11,690 --> 00:01:18,640 it's about calculating the calories, just weight in our calories control. 18 00:01:18,680 --> 00:01:20,170 So we're not going to do this. 19 00:01:20,510 --> 00:01:23,300 We are going to do it here still. 20 00:01:23,300 --> 00:01:24,280 We're going to do that. 21 00:01:24,290 --> 00:01:27,150 I mean, but here are we going to do a little bit different? 22 00:01:27,530 --> 00:01:31,630 So here we add calories and that is also connected with the calories. 23 00:01:31,940 --> 00:01:34,400 But this is coming from the front end, right? 24 00:01:34,730 --> 00:01:38,720 So here we are going to calculate the calories, but we're going to call we're going to create a couple 25 00:01:38,720 --> 00:01:43,100 of separate functions here that will go into our calories controller. 26 00:01:43,280 --> 00:01:44,000 The one on top. 27 00:01:44,000 --> 00:01:44,420 Right. 28 00:01:44,450 --> 00:01:45,590 So I'm not going to scroll down. 29 00:01:46,010 --> 00:01:48,590 So I'm going to say calculate calories here. 30 00:01:52,400 --> 00:01:55,530 You should put as much as more comments as you need. 31 00:01:55,880 --> 00:02:06,380 So the first things is to compute compute calories or to create some function so that some of the functions 32 00:02:06,380 --> 00:02:10,640 that I would like to use, I'm going to say calculate. 33 00:02:13,240 --> 00:02:17,830 And I'm going to say here, I'm going to change it, I'm going to say calories, calculation's 34 00:02:21,130 --> 00:02:28,000 function in here, I will have some functions inside and I will say, OK, I would like to say calculate. 35 00:02:31,420 --> 00:02:32,800 Come on, what's happening? 36 00:02:35,380 --> 00:02:45,640 Calculate calories in here, I will have I will call the calories controller and I will call these compute 37 00:02:47,140 --> 00:02:48,040 calories. 38 00:02:49,060 --> 00:02:51,970 This is a function that it will not take any parameters. 39 00:02:52,270 --> 00:02:57,090 But this function we haven't created yet, so we're dysfunctional will go this function. 40 00:02:57,100 --> 00:03:00,400 You already know it will go in our calories controller. 41 00:03:00,400 --> 00:03:00,710 Right. 42 00:03:01,180 --> 00:03:04,690 So it will go go up, up, up here, right. 43 00:03:04,870 --> 00:03:06,610 In our calories controller. 44 00:03:06,760 --> 00:03:08,980 In our in our public. 45 00:03:08,980 --> 00:03:09,350 Right. 46 00:03:09,700 --> 00:03:11,410 So I'm just going to write it down here. 47 00:03:13,800 --> 00:03:15,750 And we're going to call the same name, right? 48 00:03:16,020 --> 00:03:18,450 So we're going to say compute calories 49 00:03:24,030 --> 00:03:26,540 in our call is a function, right? 50 00:03:29,750 --> 00:03:30,220 Oops. 51 00:03:31,870 --> 00:03:35,780 Now, remember to put a comma here, otherwise it will not work. 52 00:03:35,950 --> 00:03:38,980 So put it just in front of the result. 53 00:03:39,010 --> 00:03:43,420 OK, here I'm just going to say print so we're not you're not going to use this after that, we're going 54 00:03:43,420 --> 00:03:43,900 to comment. 55 00:03:43,900 --> 00:03:51,910 But is good print the entire storage object, right. 56 00:03:52,030 --> 00:03:56,440 Or return the entire storage object in here. 57 00:03:56,780 --> 00:03:58,990 We will calculate. 58 00:04:02,680 --> 00:04:10,480 The cameras, no ear, we will do a couple of calculations, but in order to do that, we need to, 59 00:04:10,480 --> 00:04:16,080 for example, to create additional function and that function will be private function. 60 00:04:16,450 --> 00:04:16,810 Right. 61 00:04:17,110 --> 00:04:30,250 So this function, lets say total calories, I'm going to call it total calories in and it will accept 62 00:04:30,250 --> 00:04:31,630 one parameter here. 63 00:04:31,960 --> 00:04:33,990 These parameters will be a time. 64 00:04:34,480 --> 00:04:39,890 But because we are not passing anything to the function, I just going to manually choose to do. 65 00:04:39,980 --> 00:04:47,190 And if I'm going to call this total calories from here, I'm just going to create for the brain. 66 00:04:47,200 --> 00:04:47,590 Right. 67 00:04:47,890 --> 00:04:49,990 So these function we have not created. 68 00:04:50,140 --> 00:04:51,550 So where this function will go. 69 00:04:51,580 --> 00:04:53,500 OK, so remember this. 70 00:04:53,500 --> 00:04:54,640 We are in return. 71 00:04:54,640 --> 00:04:55,320 We are returning. 72 00:04:55,330 --> 00:04:56,250 We are in the public. 73 00:04:56,560 --> 00:05:00,370 So I just want this total calories to go above. 74 00:05:00,380 --> 00:05:05,140 So calculate the total calories in and that will go here. 75 00:05:05,770 --> 00:05:09,270 So I'm just going to create more in here. 76 00:05:09,460 --> 00:05:16,990 This function will be our core, so more total calories and it will be equal to a function with the 77 00:05:16,990 --> 00:05:17,370 time. 78 00:05:17,380 --> 00:05:20,650 Right now I can put that type here. 79 00:05:20,650 --> 00:05:27,370 Just make sure you put a semicolon tab here, because we manually, manually add this and we're going 80 00:05:27,370 --> 00:05:28,120 to read comments here. 81 00:05:28,130 --> 00:05:29,470 Don't worry about it now. 82 00:05:29,470 --> 00:05:31,300 We manually add the type there. 83 00:05:31,330 --> 00:05:33,140 Now I've got I will get the time. 84 00:05:33,520 --> 00:05:41,020 So what I want to do, remember that we have in storage all of the calories in this is an area for add 85 00:05:41,020 --> 00:05:47,620 in burns when we are adding more and more here, this area is expanding where it contains more and more 86 00:05:47,620 --> 00:05:48,300 information. 87 00:05:48,880 --> 00:05:51,660 And so we need to look through this one. 88 00:05:52,330 --> 00:05:53,320 And what are we going to do? 89 00:05:53,330 --> 00:05:54,730 We're going to use for each. 90 00:05:55,630 --> 00:05:58,710 So, number one, we're going to see a loop 91 00:06:01,790 --> 00:06:08,680 loop through the area based on its type. 92 00:06:08,730 --> 00:06:09,060 Right. 93 00:06:09,970 --> 00:06:15,090 So I'm going to create more total here and that will be zero. 94 00:06:15,430 --> 00:06:20,320 I'm going to make it to be a zero now for each. 95 00:06:20,860 --> 00:06:23,590 I'm just going to explain how the foreach loop is working. 96 00:06:23,860 --> 00:06:24,850 You already know. 97 00:06:26,110 --> 00:06:29,770 So the foreach accepts callback right. 98 00:06:29,950 --> 00:06:34,860 Function and callback with W.L.. 99 00:06:34,990 --> 00:06:38,650 So how is the name of the foreach. 100 00:06:38,830 --> 00:06:49,630 So first we need to use storage and all calories and we need to based on the type it will be for the 101 00:06:49,630 --> 00:06:50,560 at Audibert. 102 00:06:50,560 --> 00:06:54,620 So we already select storage, add calories and for example we select this one. 103 00:06:54,940 --> 00:06:59,520 So if we are adding based on that or it's going to be Burne, so we select that area. 104 00:06:59,530 --> 00:07:09,490 But how we can look through this so we can say for each just like that and it's asep a callback function. 105 00:07:09,760 --> 00:07:15,370 Now inside this, a set couple of parameters are exactly three parameters. 106 00:07:15,370 --> 00:07:26,470 I'm going to say callback function with that's why stop it with three parameters and that will be value 107 00:07:26,470 --> 00:07:32,110 current value current index and the entire 108 00:07:34,660 --> 00:07:35,060 area. 109 00:07:35,080 --> 00:07:39,470 So, so yeah I have that mista here. 110 00:07:40,480 --> 00:07:44,740 Now this function accepts three, as I told you, three parameters. 111 00:07:44,740 --> 00:07:45,030 Right. 112 00:07:45,280 --> 00:07:53,920 And for now we don't need the entire we don't need the index, we don't need the entire area because 113 00:07:53,920 --> 00:07:55,170 we are looking through this area. 114 00:07:55,330 --> 00:07:58,960 But what we need here, I just need the current right. 115 00:07:59,740 --> 00:08:03,130 The current current value. 116 00:08:03,310 --> 00:08:07,030 OK, now so how are we going to do this? 117 00:08:07,030 --> 00:08:08,650 Because I have this total here. 118 00:08:08,650 --> 00:08:13,210 I'm just going to write the function, the core function, and after that I'm going to explain it how 119 00:08:13,690 --> 00:08:20,860 plus equal or this is same as total equal total plus. 120 00:08:20,860 --> 00:08:23,440 And after that we continue doing what we are doing right. 121 00:08:23,590 --> 00:08:28,060 So that this, this and this is same. 122 00:08:28,210 --> 00:08:28,600 Right. 123 00:08:29,200 --> 00:08:30,490 We use that one before. 124 00:08:30,500 --> 00:08:37,220 Now you know how I'm not going to I'm going to use the short version so total that will be equal to 125 00:08:37,220 --> 00:08:40,360 the current calories. 126 00:08:43,840 --> 00:08:51,580 Right, dot, dot, dot, sorry, multiplied by the current quantity. 127 00:08:54,040 --> 00:09:00,310 Now how I get this one well inside this one, what we have, we have the calories and we have quantity. 128 00:09:00,340 --> 00:09:01,600 That's why I can grab those. 129 00:09:01,630 --> 00:09:03,730 I have these four values here. 130 00:09:03,730 --> 00:09:04,480 I can use them. 131 00:09:04,480 --> 00:09:06,280 I can get the idea, but I don't need the 80. 132 00:09:06,610 --> 00:09:12,470 So the total will hold the current calories multiplied by the quantity. 133 00:09:12,490 --> 00:09:18,880 So if we have 50 calories and two of the quantity, that means it's a hundred and it will be saved here 134 00:09:18,880 --> 00:09:19,510 in total. 135 00:09:19,720 --> 00:09:23,350 So mind we just initialize the total before you. 136 00:09:23,620 --> 00:09:24,720 So how would this work? 137 00:09:24,880 --> 00:09:27,990 OK, let me just write down a simple example. 138 00:09:28,330 --> 00:09:36,640 For example, in our we are working with our Ed Henry here, and I'm going to create a nursery here 139 00:09:36,640 --> 00:09:38,200 saying, OK, I have 50. 140 00:09:39,160 --> 00:09:41,430 I say five fifty five. 141 00:09:41,800 --> 00:09:42,180 What else? 142 00:09:42,190 --> 00:09:46,360 I have one hundred and five and thirty six, for example. 143 00:09:46,360 --> 00:09:53,680 You can choose whatever colors you want in here will be the index, which we are not using at the moment. 144 00:09:53,680 --> 00:09:53,980 Right. 145 00:09:54,250 --> 00:09:56,020 Start from the zero position. 146 00:09:56,890 --> 00:10:00,240 It goes to the first, it goes to the second and third. 147 00:10:00,370 --> 00:10:06,070 So we have three actually elements inside, but we have four because we're starting from this zero. 148 00:10:06,380 --> 00:10:07,450 So how is this going to work? 149 00:10:07,780 --> 00:10:18,120 OK, let's put it like that and we're going to say, number one, the total will be equal to zero. 150 00:10:18,130 --> 00:10:18,430 Right. 151 00:10:19,600 --> 00:10:21,850 Or I'm not going to just put it as a number one. 152 00:10:22,150 --> 00:10:27,370 I'm just going to say the total will be equal to zero because that is what we have before we going in 153 00:10:27,370 --> 00:10:28,540 looping through the Herry. 154 00:10:28,930 --> 00:10:40,480 So after that, the total will be total, plus the value, the current value of this index. 155 00:10:40,490 --> 00:10:41,590 So it's going to be five. 156 00:10:41,590 --> 00:10:41,880 Right. 157 00:10:42,100 --> 00:10:45,370 So that will be zero plus five. 158 00:10:45,670 --> 00:10:47,380 It will be five. 159 00:10:48,250 --> 00:10:51,260 How cool is this right now, the next one. 160 00:10:51,280 --> 00:10:52,750 So this is going to be number one. 161 00:10:54,060 --> 00:11:04,630 Number two is going to be total equal total plus this element here with the value of fifty five and 162 00:11:04,630 --> 00:11:09,600 that will be five plus fifty five and that will be sixteen. 163 00:11:09,970 --> 00:11:15,040 So see how we are doing before was zero plus five, it's five. 164 00:11:15,340 --> 00:11:17,830 And we are adding this value as a total here. 165 00:11:17,840 --> 00:11:24,910 I don't want to write five plus fifty fifty five to go exactly like it's math, but I just wanted to 166 00:11:24,910 --> 00:11:26,230 make it a little bit simpler. 167 00:11:26,620 --> 00:11:36,970 So total it will be equal to total plus one hundred and five in the value will be 60 plus a hundred 168 00:11:36,970 --> 00:11:43,450 and five and that will be one sixty five in the last step that this is going to loop through the last 169 00:11:43,450 --> 00:11:43,960 element. 170 00:11:44,170 --> 00:11:47,080 So it's going to iterate how many times. 171 00:11:47,290 --> 00:11:47,920 Four times. 172 00:11:47,920 --> 00:11:48,310 Right. 173 00:11:48,760 --> 00:11:53,850 And we will see total plus thirty six and that will be equal. 174 00:11:53,870 --> 00:11:59,050 One hundred sixty five plus thirty six and that will give us two a one. 175 00:11:59,170 --> 00:12:02,380 So the value that I'm getting here is going there. 176 00:12:02,560 --> 00:12:08,230 The value that I'm getting here is going there, the value that I'm getting here is going there is the 177 00:12:08,230 --> 00:12:11,530 final result will be two oh one. 178 00:12:12,280 --> 00:12:12,700 Right. 179 00:12:13,040 --> 00:12:21,010 So this is I'm going to leave it like this is what I can do is actually I can just create. 180 00:12:23,520 --> 00:12:27,070 Just like that, and, yeah, it's going to simplify the way. 181 00:12:27,390 --> 00:12:31,730 Now this is the way how are we going to calculate how this for each loop? 182 00:12:31,980 --> 00:12:39,930 So we are just using the storage, we are getting the all calories and this object contains to erase. 183 00:12:40,170 --> 00:12:44,910 And based on the time we are looping through that particular area, if it's for burning, real looping 184 00:12:44,910 --> 00:12:52,320 there in here, we call those we just call this function with this name, which just providing the time. 185 00:12:52,620 --> 00:12:53,000 Right. 186 00:12:53,190 --> 00:13:01,310 And now what we need to do is actually inside our global storage here. 187 00:13:02,730 --> 00:13:06,780 We haven't done this inside our global storage object. 188 00:13:06,780 --> 00:13:10,320 We will need to have all some calories. 189 00:13:10,320 --> 00:13:18,090 Herry, we need to have additional Aeris in order or we need to have another object with two values 190 00:13:18,120 --> 00:13:18,540 there. 191 00:13:18,630 --> 00:13:18,960 Right. 192 00:13:19,140 --> 00:13:23,530 In order to save this data, because I'm going to get some result here like two one. 193 00:13:23,640 --> 00:13:24,770 So where I'm going to save it. 194 00:13:24,990 --> 00:13:30,010 So I'm going to save it back as an object here in it. 195 00:13:30,100 --> 00:13:38,130 We need comma here and I'm going to see and it will be so I'm going to say it will be zero and burn. 196 00:13:38,340 --> 00:13:39,220 It will be zero. 197 00:13:39,240 --> 00:13:46,290 So when I started this program, when I started when I initiated this program, this all will have we 198 00:13:46,290 --> 00:13:49,080 will they will have add and burn to zero. 199 00:13:49,080 --> 00:13:54,390 But now when I do this, I do have to 201 for the end. 200 00:13:54,870 --> 00:13:57,200 But at the moment I'm just looping through them. 201 00:13:57,210 --> 00:13:58,770 So now I need to store them here. 202 00:13:58,920 --> 00:14:02,140 So how I'm going to store it, that's very easy. 203 00:14:02,160 --> 00:14:10,350 So same storage dot and now I'm going to see all in inside, all based of our type. 204 00:14:10,860 --> 00:14:12,230 That's why we use typewrite. 205 00:14:12,240 --> 00:14:13,670 That's why we use add and burn. 206 00:14:13,860 --> 00:14:14,850 Based on our time. 207 00:14:14,850 --> 00:14:16,290 It will be add or burn. 208 00:14:16,560 --> 00:14:24,430 I'm going to store this total variable here so the value of the total will go there. 209 00:14:24,450 --> 00:14:26,590 So if it's for burning, it will save it there. 210 00:14:26,730 --> 00:14:28,470 So it's not going to be zero anymore. 211 00:14:28,650 --> 00:14:31,530 Right, because we are looking through all the items inside. 212 00:14:32,010 --> 00:14:36,550 We are looking through all of their values and we're putting back in the storage. 213 00:14:36,900 --> 00:14:38,210 So that is pretty much it. 214 00:14:38,460 --> 00:14:46,920 We are done now when I call this, when it will be called, they will loop through these areas here 215 00:14:46,920 --> 00:14:48,680 and they will see the results here. 216 00:14:49,080 --> 00:14:59,640 So I hope I'm clear now, like make another comment here, make another comment and see inside our global 217 00:15:00,060 --> 00:15:04,710 storage storage object. 218 00:15:05,310 --> 00:15:20,790 Add another object where we store the total that the total value of the end and burn calories. 219 00:15:24,220 --> 00:15:31,090 I hope this is going to say so, that's why we create this er all object here. 220 00:15:31,300 --> 00:15:36,640 OK, so we need to work now here, right. 221 00:15:36,660 --> 00:15:38,080 So we do have that one. 222 00:15:38,320 --> 00:15:39,790 Don't worry, we're going to use that. 223 00:15:39,790 --> 00:15:46,540 So we are we're not nearly there, but we now we need to calculate how much calories have been left. 224 00:15:46,750 --> 00:15:47,870 So how are we going to do this. 225 00:15:47,920 --> 00:15:48,340 Oh yeah. 226 00:15:48,580 --> 00:15:50,890 Let's say I'm going to say storage. 227 00:15:53,110 --> 00:15:58,240 So storage is for this reason, I need to create an additional variable there. 228 00:15:58,620 --> 00:16:06,610 We have to show property and I will say total calories per per day, OK? 229 00:16:06,790 --> 00:16:10,180 And the total calories per day will be storage. 230 00:16:11,230 --> 00:16:17,570 Not all that at minus storage that all that burn. 231 00:16:18,310 --> 00:16:21,510 So imagine that this will return. 232 00:16:21,550 --> 00:16:25,350 This will create this will save in the in the storage to five. 233 00:16:26,080 --> 00:16:26,440 Right. 234 00:16:26,470 --> 00:16:30,030 And this will save one hundred sixty five. 235 00:16:30,040 --> 00:16:30,330 Right. 236 00:16:30,850 --> 00:16:37,180 And now I'm accessing the storage, I'm accessing this property which I don't have it at the moment, 237 00:16:37,390 --> 00:16:39,270 which will we will create it now. 238 00:16:39,460 --> 00:16:43,030 So we need to create OK, I'm going to create a couple of them. 239 00:16:43,210 --> 00:16:45,670 So just do this together with me. 240 00:16:45,790 --> 00:16:53,380 After that it will be all clear, total calories per day and I'm going to be set to zero. 241 00:16:58,190 --> 00:16:59,520 Total calories per day. 242 00:16:59,690 --> 00:17:05,990 I'm going to put an additional property here, Minkow per day, and I'm going to set the two thousand 243 00:17:05,990 --> 00:17:06,670 three hundred. 244 00:17:06,680 --> 00:17:09,190 Remember when I told you that you can set your own value? 245 00:17:09,380 --> 00:17:14,570 So if you want these in your body mass index, based on the size, based on the height, there is a 246 00:17:14,570 --> 00:17:14,990 function. 247 00:17:14,990 --> 00:17:20,210 You can find it online and you can say, OK, I need to burn this. 248 00:17:20,330 --> 00:17:24,140 I need to take this amount of calories per day. 249 00:17:24,560 --> 00:17:30,230 I just I'm putting this average because for girls around two thousand and four boys, it's a two thousand 250 00:17:30,230 --> 00:17:30,800 five hundred. 251 00:17:30,800 --> 00:17:33,710 So that's why I just put it somewhere in between. 252 00:17:33,720 --> 00:17:34,030 Right. 253 00:17:34,580 --> 00:17:35,590 And yeah. 254 00:17:35,930 --> 00:17:37,940 Now I was also percentage. 255 00:17:40,960 --> 00:17:49,450 And that will be zero again and what else we do have here and remaining, and that will be zero. 256 00:17:49,520 --> 00:17:49,810 Wow. 257 00:17:50,250 --> 00:17:54,100 OK, so that will go for this remaining. 258 00:17:54,100 --> 00:18:01,150 That will go for this percentage and for the total calories and burn calories will go here. 259 00:18:01,180 --> 00:18:02,220 OK, let's start working. 260 00:18:02,560 --> 00:18:06,780 So I have these in our storage, these four properties. 261 00:18:06,790 --> 00:18:07,980 So what I'm going to do with them. 262 00:18:08,410 --> 00:18:15,130 So first I call the storage of total calories, which will be zero is basically the same as what we 263 00:18:15,130 --> 00:18:25,480 did here with the we just put it here right now, you know, and I say, OK, now the total calories 264 00:18:26,110 --> 00:18:33,820 per day, it will be two hundred and five minus one hundred sixty five. 265 00:18:33,820 --> 00:18:35,890 And that will give me a result of forty. 266 00:18:36,100 --> 00:18:40,570 So the total calories per day, I will have 40. 267 00:18:40,780 --> 00:18:41,140 Right. 268 00:18:41,260 --> 00:18:44,200 And I will store them here now. 269 00:18:44,200 --> 00:18:45,290 Mean calories per day. 270 00:18:45,310 --> 00:18:47,610 OK, what are we going to do with mean calories per day. 271 00:18:47,890 --> 00:18:49,240 So we're going to use that mean calories. 272 00:18:49,240 --> 00:18:54,920 Don't worry, we're going to use that for the calculating the remaining right. 273 00:18:55,300 --> 00:18:55,650 Okay. 274 00:18:58,710 --> 00:18:59,580 Where we were. 275 00:19:01,810 --> 00:19:05,920 Yeah, now I'm going to say store. 276 00:19:08,910 --> 00:19:21,390 Stora, I'm going to put a store story back to our global storage, what total calories per day? 277 00:19:23,860 --> 00:19:24,370 Come on. 278 00:19:26,010 --> 00:19:26,220 Oh. 279 00:19:26,740 --> 00:19:32,350 Now here, I'm going to copy this one and I'm going to put it like this story back in our global storage 280 00:19:33,250 --> 00:19:36,920 now mean calories per day, right? 281 00:19:37,690 --> 00:19:38,230 Remaining. 282 00:19:38,230 --> 00:19:38,590 Sorry. 283 00:19:41,720 --> 00:19:51,410 So how are we going to do this storage not remaining here, so I grab that one, it's 2300 and I'm going 284 00:19:51,410 --> 00:19:55,250 to say, OK, storage not remaining, I'm going to call it again. 285 00:19:55,610 --> 00:20:02,870 And it will be minus the storage, that total calories per day. 286 00:20:06,710 --> 00:20:13,400 Remember that we see this guy here, he's going to have 40, for example, right, you save it 40 and 287 00:20:13,400 --> 00:20:15,560 it will be 2300, minus 40. 288 00:20:16,220 --> 00:20:16,610 Right. 289 00:20:16,770 --> 00:20:18,140 That is the logic. 290 00:20:19,100 --> 00:20:22,560 So the last part is we need to calculate the percentage. 291 00:20:22,790 --> 00:20:23,570 So how are we going to do this? 292 00:20:23,600 --> 00:20:29,480 I'm just going to copy this guy here and calculate. 293 00:20:32,140 --> 00:20:34,340 In the store, that percentage. 294 00:20:41,020 --> 00:20:49,180 And here should be saying calculate in store right now here we are going to call the percentage, the 295 00:20:49,180 --> 00:20:51,650 percentage is zero at the moment, right. 296 00:20:51,850 --> 00:20:52,710 So how are we going to do that? 297 00:20:52,870 --> 00:20:59,230 So storage, not total calories, just going to remove this because we don't need it and that I'm going 298 00:20:59,230 --> 00:21:10,780 to divide it by the storage that mean calories per day that the formula used to multiply by 100. 299 00:21:13,340 --> 00:21:13,790 Right. 300 00:21:15,740 --> 00:21:23,720 So what we're going to have, for example, I have let's say that I have the example is percentage. 301 00:21:26,840 --> 00:21:33,740 It will be, for example, seven hundred divided by two thousand three hundred. 302 00:21:34,130 --> 00:21:38,650 And after that, we're going to multiply by a hundred. 303 00:21:40,040 --> 00:21:47,140 OK, so let's use the calculator and see seven hundred divided by two thousand three hundred. 304 00:21:47,360 --> 00:21:48,470 That will give me this. 305 00:21:48,480 --> 00:21:52,540 If I multiply by 100, it will give me 30 percent. 306 00:21:52,880 --> 00:22:02,990 But look, it is it will give me that will give me thirty point forty three percent so we can use another 307 00:22:03,860 --> 00:22:08,060 math object and use Routon method to calculate the percentage. 308 00:22:08,300 --> 00:22:15,680 Remember we have done this, so I'm going to call this math round and that will give me a nice round 309 00:22:15,680 --> 00:22:16,530 of this one. 310 00:22:16,760 --> 00:22:21,860 So but I need I need to grab this cut it here. 311 00:22:22,370 --> 00:22:24,320 I'm going to put up inside the brackets. 312 00:22:24,320 --> 00:22:26,210 Otherwise it will work. 313 00:22:26,210 --> 00:22:27,590 But it's better like this. 314 00:22:27,650 --> 00:22:28,790 So we're done. 315 00:22:29,630 --> 00:22:33,380 This is how are we going to calculate this is how we are going to do now. 316 00:22:33,380 --> 00:22:34,370 What's next? 317 00:22:35,240 --> 00:22:40,960 Well, next year I need to return everything that I have just calculated. 318 00:22:41,150 --> 00:22:44,870 So I'm just going to create a function here called return. 319 00:22:48,640 --> 00:22:59,110 Return calories and I'm going to say function and comma here and I'm going to put a comment here saying, 320 00:22:59,110 --> 00:23:09,370 OK, so what will we get data from the storage storage and 321 00:23:11,950 --> 00:23:17,510 then return it as an object? 322 00:23:17,680 --> 00:23:18,030 Right. 323 00:23:18,070 --> 00:23:19,320 We have done this in past. 324 00:23:19,480 --> 00:23:22,000 So how what what is the goal here? 325 00:23:22,270 --> 00:23:26,680 The goal here is to return all of this. 326 00:23:27,100 --> 00:23:27,480 Right. 327 00:23:27,610 --> 00:23:28,690 So I'm just going to copy them. 328 00:23:29,140 --> 00:23:33,280 And what I'm going to do, I'm just going to return them as a one big object. 329 00:23:33,280 --> 00:23:37,200 Right, because I'm going to return multiple data as an object. 330 00:23:39,530 --> 00:23:44,630 So what I'm going to do, I'm going to say, OK, I'm just going to put it like that and I'm going to 331 00:23:44,630 --> 00:23:50,150 say, OK, today, calories, you can write any name you want. 332 00:23:50,390 --> 00:23:55,880 So here I'm going to call the storage that today's calories. 333 00:23:56,630 --> 00:23:58,810 Right, because we're not doing anything else. 334 00:23:59,090 --> 00:24:06,980 Now, here what I will say, I will say total edit and how I'm going to grab the total edit. 335 00:24:06,980 --> 00:24:08,480 The total will be storage. 336 00:24:09,230 --> 00:24:12,080 Not all that bad. 337 00:24:14,130 --> 00:24:14,580 Right. 338 00:24:15,200 --> 00:24:21,550 So I'm just going to call a comma here total burn. 339 00:24:22,590 --> 00:24:25,940 So we need to do storage that old burn. 340 00:24:26,150 --> 00:24:26,540 Right. 341 00:24:26,780 --> 00:24:29,120 I'm grabbing all of these that we're going to need. 342 00:24:29,660 --> 00:24:30,100 Right. 343 00:24:30,110 --> 00:24:35,240 So I'm grabbing the what we stored from this function here, from this little here. 344 00:24:36,350 --> 00:24:40,210 What else we need, comma should be there remaining. 345 00:24:41,990 --> 00:24:43,970 I'm going to cut it from here remaining. 346 00:24:44,120 --> 00:24:46,460 I'm going to say, OK, storage 347 00:24:49,130 --> 00:24:52,820 remaining and the last one will be percentage. 348 00:24:52,820 --> 00:24:53,980 And I don't need this mingalar. 349 00:24:54,050 --> 00:24:55,690 If you want, you can return that one as well. 350 00:24:55,940 --> 00:24:56,290 Right. 351 00:24:56,420 --> 00:25:02,510 The percentage it will be storage, that percentage it pretty much will return. 352 00:25:02,510 --> 00:25:02,950 Whatever. 353 00:25:02,960 --> 00:25:11,230 What what was the entire what we what we calculate here or compute here and here. 354 00:25:11,240 --> 00:25:13,580 So that is pretty much done. 355 00:25:14,030 --> 00:25:18,170 So what we need to do now, now we need to do a couple of things. 356 00:25:18,170 --> 00:25:20,510 We need to call this one somewhere. 357 00:25:20,510 --> 00:25:22,790 We need to call this function in two places. 358 00:25:23,180 --> 00:25:24,710 You're going to see why. 359 00:25:24,840 --> 00:25:27,920 OK, we are going down here. 360 00:25:29,540 --> 00:25:37,010 So already called the computer calories, but now I just want to get the calories right and I'm going 361 00:25:37,010 --> 00:25:45,380 to create a variable here, calories, and I'm going to store what we return very so sorry calories. 362 00:25:47,450 --> 00:25:55,400 And that will be equal to what calories controller and that will be able to get access to return calories, 363 00:25:55,640 --> 00:25:56,570 this function here. 364 00:25:56,570 --> 00:25:58,970 And it didn't require any parameters. 365 00:25:59,360 --> 00:26:04,220 So I'm just going to get get computed. 366 00:26:11,200 --> 00:26:20,300 From compute calories at function in what was the other function name, let's see. 367 00:26:21,220 --> 00:26:22,780 Total, I think total calories. 368 00:26:23,440 --> 00:26:28,860 So we are going to get all all these data from these two, right. 369 00:26:37,900 --> 00:26:45,500 And like that, no, I did have this one inside here, the only thing that remains is to control all 370 00:26:45,510 --> 00:26:47,230 of these calories and we are done. 371 00:26:47,270 --> 00:26:52,190 I know this lecture will be super, super long, but I'm sorry about this, guys. 372 00:26:57,770 --> 00:27:05,700 Yeah, now, one more thing here, we need to call this function, calculate calories. 373 00:27:05,720 --> 00:27:11,560 Remember, we haven't call it anywhere and I just want to call it just right below here. 374 00:27:11,840 --> 00:27:16,440 So while we are doing this, otherwise it will not be initiated, right? 375 00:27:16,790 --> 00:27:18,660 It will not be called in. 376 00:27:18,780 --> 00:27:20,630 The calculation will not be done. 377 00:27:20,990 --> 00:27:22,010 So calculate 378 00:27:25,250 --> 00:27:26,000 related 379 00:27:28,700 --> 00:27:29,630 functions. 380 00:27:30,750 --> 00:27:36,630 And I'm going to call it here, calculate calories like that so I can do it because it's in in this 381 00:27:36,630 --> 00:27:37,380 scope here. 382 00:27:37,890 --> 00:27:39,520 So I hope this is done. 383 00:27:39,540 --> 00:27:41,560 Now, I'm just going to close this. 384 00:27:42,840 --> 00:27:43,680 I hope it's going to work. 385 00:27:43,680 --> 00:27:44,850 So I'm going to add a calorie. 386 00:27:44,860 --> 00:27:46,010 I'm going to inspect it. 387 00:27:46,410 --> 00:27:55,200 And if we have some error, it will be fun because we will need to what we will need to get rid of that 388 00:27:55,200 --> 00:27:55,560 error. 389 00:27:55,710 --> 00:27:57,030 OK, now for the food. 390 00:27:57,030 --> 00:28:03,570 I'm going to say salad one hundred seventy seventy five point this. 391 00:28:04,170 --> 00:28:05,130 So we're going to add it. 392 00:28:05,460 --> 00:28:06,170 Here it is. 393 00:28:06,420 --> 00:28:09,120 So I have this to these calories. 394 00:28:09,120 --> 00:28:10,830 It will be this total. 395 00:28:10,830 --> 00:28:11,250 Add it. 396 00:28:11,640 --> 00:28:16,560 How cool is this to burn the zero remaining in? 397 00:28:16,560 --> 00:28:19,140 Why is giving me this error here? 398 00:28:19,140 --> 00:28:24,150 I'm not sure the remaining should be go back. 399 00:28:27,040 --> 00:28:35,760 So we need to find out what's wrong with the remaining right instead of here putting the missing calories, 400 00:28:35,770 --> 00:28:41,560 but yeah, the mean calories per day, I just put that remaining and that's why it's not working. 401 00:28:41,590 --> 00:28:43,210 OK, here one. 402 00:28:43,210 --> 00:28:45,670 But let's hope is going to be fix it. 403 00:28:45,910 --> 00:28:50,680 Salyut one hundred seventy eight point nine. 404 00:28:50,870 --> 00:28:52,680 OK, here it is now. 405 00:28:52,690 --> 00:28:54,750 It's working now from 2300. 406 00:28:55,000 --> 00:28:58,830 This 178 is substract and the percentage is eight. 407 00:28:59,050 --> 00:29:00,670 OK, let's add another one. 408 00:29:00,670 --> 00:29:04,330 Ice cream, one fifty five calories. 409 00:29:04,840 --> 00:29:05,370 Cool. 410 00:29:05,740 --> 00:29:11,140 Now it's added seven one hundred and seventy eight before plus fifty five is going to give you this. 411 00:29:11,410 --> 00:29:13,300 Let's add one more. 412 00:29:13,300 --> 00:29:17,350 What will that coffee there. 413 00:29:18,550 --> 00:29:19,750 And I will say one. 414 00:29:19,780 --> 00:29:22,720 I will say how cool is this. 415 00:29:22,730 --> 00:29:27,610 Now let's Bernsten running one lap. 416 00:29:28,450 --> 00:29:32,680 Two hundred and fifty and this percentage should drop and this should go up. 417 00:29:32,680 --> 00:29:33,000 Right. 418 00:29:33,010 --> 00:29:33,910 That's the logic. 419 00:29:34,510 --> 00:29:34,870 Right. 420 00:29:35,020 --> 00:29:40,360 The percentage should drop is drop and the remaining is this almost. 421 00:29:40,900 --> 00:29:41,320 Yeah. 422 00:29:41,350 --> 00:29:45,400 And today's calories are burned today at it. 423 00:29:45,400 --> 00:29:52,610 It will be this to the burn this and these to these calories is the when you subtract this minus this. 424 00:29:52,840 --> 00:30:00,850 So I hope you enjoy this lecture and we are getting there now the last part we need to put these results 425 00:30:00,850 --> 00:30:02,680 that we have it here right. 426 00:30:02,990 --> 00:30:07,930 Updated in our front in the front app. 427 00:30:07,930 --> 00:30:08,310 Right. 428 00:30:08,320 --> 00:30:09,530 So that's pretty much it. 429 00:30:09,550 --> 00:30:11,020 Super long lecture. 430 00:30:11,020 --> 00:30:12,010 Sorry about this. 431 00:30:12,290 --> 00:30:13,510 Hope to see you in the next one.