1 00:00:01,650 --> 00:00:08,100 OK, ladies and gentlemen, today is one of the most interesting lectures where we are going to add 2 00:00:08,340 --> 00:00:13,900 our calories for the first time in the storage object that we created. 3 00:00:13,920 --> 00:00:16,090 Right now, how are we going to do this? 4 00:00:17,490 --> 00:00:25,350 So the idea is here to create a function with with the name at CALORIE. 5 00:00:26,160 --> 00:00:34,500 And that function will be pretty much here above above the result, because we need to return the result 6 00:00:34,500 --> 00:00:40,200 from adding and storing the data inside those these objects. 7 00:00:40,300 --> 00:00:40,670 Right. 8 00:00:40,980 --> 00:00:49,350 But if you ask yourself how we can do this first, we need here we just cancel like the input. 9 00:00:49,350 --> 00:00:50,970 We just read the data first. 10 00:00:51,370 --> 00:01:02,760 Right now, the second part is that we will do is pretty much, I'm going to say not read the data at 11 00:01:04,800 --> 00:01:09,330 CALORIE and here I'm going to call a function. 12 00:01:09,750 --> 00:01:14,330 So this function will be inside calories controller. 13 00:01:14,460 --> 00:01:21,210 So I'm going to add the calories control or not add calorie might this function is not created here. 14 00:01:21,960 --> 00:01:22,320 Right. 15 00:01:23,490 --> 00:01:25,410 So let's create this function here. 16 00:01:25,950 --> 00:01:28,940 And as I told you, this is a return. 17 00:01:28,950 --> 00:01:30,410 This is just a test. 18 00:01:30,420 --> 00:01:32,010 After that, we can just delete it. 19 00:01:32,010 --> 00:01:39,420 But here I'm going to say at calorie like that, and I'm just going to say it's a function. 20 00:01:40,740 --> 00:01:44,880 We doubt it's going to take some parameters in here. 21 00:01:44,910 --> 00:01:53,340 Don't forget about this comment right now what type of parameters we need to have in order these calorie 22 00:01:53,340 --> 00:01:54,260 to function. 23 00:01:54,660 --> 00:02:02,720 So here, remember that in this get I'm just going to show you in this get for me. 24 00:02:02,730 --> 00:02:06,770 But we did get the data from our forum, right. 25 00:02:07,860 --> 00:02:09,810 So we're going to parse the same object. 26 00:02:09,810 --> 00:02:16,260 So we have two options here to parse the entire object like this. 27 00:02:17,520 --> 00:02:25,710 And let's go back here and we need to see form object and these form object. 28 00:02:25,710 --> 00:02:30,870 We're going to see console log, for example, form object. 29 00:02:30,960 --> 00:02:32,270 And I can access the type. 30 00:02:32,430 --> 00:02:32,740 Right. 31 00:02:33,810 --> 00:02:35,430 Let's see if it's going to work or not. 32 00:02:35,730 --> 00:02:41,310 So this is one of the way I'm going to show you the type is going to be at right. 33 00:02:41,580 --> 00:02:49,390 Food one one hit enter and let's see if we expect it at something we'll have. 34 00:02:49,830 --> 00:02:51,330 Yeah, it will be air. 35 00:02:51,930 --> 00:02:53,340 So we will have objects. 36 00:02:54,910 --> 00:03:02,230 And we will have these ads, right, because that is pretty much it for this, if I go to exercise, 37 00:03:02,590 --> 00:03:08,920 if I put here E, for example, if I click it again, let's refresh. 38 00:03:11,430 --> 00:03:14,850 And still, for some reason, I do have that result there. 39 00:03:15,420 --> 00:03:17,190 Sometimes this can be stopped. 40 00:03:17,220 --> 00:03:18,040 Don't worry about it. 41 00:03:18,420 --> 00:03:22,830 You need to be just learn to be patient and one one. 42 00:03:23,010 --> 00:03:23,710 And here it is. 43 00:03:23,790 --> 00:03:24,910 It's going to be brain, right. 44 00:03:26,550 --> 00:03:33,300 This is what I would expect if I put exercise food in here that we don't need to change is going to 45 00:03:33,300 --> 00:03:33,470 be. 46 00:03:33,480 --> 00:03:39,240 And in this time, it's coming from where we did Kunzel like these. 47 00:03:40,390 --> 00:03:41,310 Get warm. 48 00:03:41,870 --> 00:03:42,940 Right, you can just. 49 00:03:44,540 --> 00:03:55,310 Comin out now you can do this or you can do it like get form, input, dot type, comma. 50 00:03:56,380 --> 00:04:02,930 Get for me and put that what else we need here, so I do have a description. 51 00:04:03,220 --> 00:04:09,980 I do have gift for input calories and get for me food quality. 52 00:04:10,480 --> 00:04:10,760 Right. 53 00:04:11,200 --> 00:04:12,490 So we can do that. 54 00:04:12,490 --> 00:04:13,180 But here. 55 00:04:15,460 --> 00:04:21,820 Where it is, I get lost for a second here in this one. 56 00:04:22,030 --> 00:04:23,740 So here we don't have object. 57 00:04:23,740 --> 00:04:24,850 We have four values. 58 00:04:25,000 --> 00:04:28,290 It will be a type description. 59 00:04:29,170 --> 00:04:30,190 You can just change it. 60 00:04:30,200 --> 00:04:34,240 You can name these parameters from this function, whatever you want. 61 00:04:34,240 --> 00:04:38,980 You can just put it to the yeah. 62 00:04:38,980 --> 00:04:42,820 What else type description, calories and quantities. 63 00:04:42,820 --> 00:04:45,790 You can do it like this, but I'm going to just use the same names. 64 00:04:46,150 --> 00:04:48,940 But you can use whatever you want. 65 00:04:50,720 --> 00:04:56,430 And this will be description, and here it will be time. 66 00:04:56,750 --> 00:05:00,110 So now I will not be able to use this object anymore. 67 00:05:00,140 --> 00:05:05,830 First, we don't have it here, but I can straight access to type here. 68 00:05:06,920 --> 00:05:10,910 Or just put a description now, it will be more interesting, right? 69 00:05:11,570 --> 00:05:16,060 So I'm just going to refresh here and here for some reason, everything. 70 00:05:16,760 --> 00:05:18,740 So food doesn't matter what we got to say. 71 00:05:18,740 --> 00:05:20,470 Food here, one one. 72 00:05:20,690 --> 00:05:24,620 And he's entertaining his food, food or hear ice cream. 73 00:05:25,590 --> 00:05:27,800 It will be ice cream if I have. 74 00:05:27,980 --> 00:05:28,600 Does it matter? 75 00:05:28,640 --> 00:05:30,010 I'm not checking for the type anymore. 76 00:05:30,200 --> 00:05:34,850 So now you know how you can pass these data that we have from the form. 77 00:05:37,320 --> 00:05:39,400 And sorry, I'm thinking something else. 78 00:05:39,420 --> 00:05:47,010 That's why I just go around like that so you can basically hear what I just always want to do because 79 00:05:47,010 --> 00:05:48,450 I don't want to make this too long. 80 00:05:48,610 --> 00:05:50,670 I'm just going to pass the entire object. 81 00:05:52,480 --> 00:05:53,410 In here. 82 00:05:55,990 --> 00:06:02,830 I'm just going to say, OK, input object right here, what I'm going to do is I'm going to say VoIP 83 00:06:02,830 --> 00:06:09,100 type, comma, description, comma, and what else we need here. 84 00:06:09,400 --> 00:06:11,290 That description, calories. 85 00:06:13,340 --> 00:06:20,090 Quantity, right, and what I can do is I can say type, it will be equal to input object. 86 00:06:20,540 --> 00:06:30,290 That type description will be equal to input object description calories will be 87 00:06:32,900 --> 00:06:40,890 calories will be input input, object calories in quantity will be input, object quantity. 88 00:06:41,960 --> 00:06:45,050 Right now this will work. 89 00:06:45,080 --> 00:06:50,380 Now again, let's choose to choose the calories for it. 90 00:06:50,600 --> 00:06:56,500 This will work because it grab from input object and I save it into this variable here on the left. 91 00:06:56,870 --> 00:06:57,280 All right. 92 00:06:57,500 --> 00:06:58,810 So I'm just going to close it. 93 00:06:58,820 --> 00:07:02,660 I don't know what is happening today, but I have too many things right. 94 00:07:02,850 --> 00:07:09,920 And I hate for some reason now this fire of this Google Chrome is getting out of control. 95 00:07:09,920 --> 00:07:11,210 So food, ice cream. 96 00:07:11,210 --> 00:07:11,510 Right. 97 00:07:11,810 --> 00:07:13,280 And here it will be one. 98 00:07:13,280 --> 00:07:15,200 The calories will be one seven seven. 99 00:07:15,530 --> 00:07:16,060 Let's see. 100 00:07:16,070 --> 00:07:16,420 Yep. 101 00:07:16,430 --> 00:07:17,330 Here is the calories. 102 00:07:17,330 --> 00:07:20,150 If I change the calories to two or three, it will be two three. 103 00:07:20,180 --> 00:07:21,350 So that's it. 104 00:07:21,830 --> 00:07:23,630 I prefer doing this way. 105 00:07:24,770 --> 00:07:29,900 So I have saved all of this into a variables. 106 00:07:30,080 --> 00:07:31,370 So let's move on now. 107 00:07:31,400 --> 00:07:32,960 What is the idea here? 108 00:07:33,200 --> 00:07:42,680 The idea here is to have two based on what we are trying to see if we are adding a calories or we are 109 00:07:42,680 --> 00:07:47,210 burning calories, we are going to show based on the type. 110 00:07:47,210 --> 00:07:51,020 Actually, we are going to create a new instance in here. 111 00:07:51,020 --> 00:07:58,040 I'm going to see new calorie and you will see why this new calorie I mean, now, based on if I'm going 112 00:07:58,040 --> 00:08:04,370 to eat condition based on the type, if the type is equal, equal to at. 113 00:08:07,270 --> 00:08:13,680 Or else, if time is equal, equal to burn, right? 114 00:08:14,000 --> 00:08:23,000 So I know this that is why we create this ad in burn areas, because they do have the same name and 115 00:08:23,000 --> 00:08:26,340 are also in the in the HDMI. 116 00:08:26,420 --> 00:08:31,280 I do have for the option I do have and this is not like random. 117 00:08:31,290 --> 00:08:36,950 This is this is like that because after that you will see I'm just going to use the type, whatever 118 00:08:36,950 --> 00:08:38,680 that that is and I'm going to store. 119 00:08:38,930 --> 00:08:41,780 So here I'm going to use I'm going to create a new instance. 120 00:08:43,220 --> 00:08:54,230 So new Kaleri and that will be equal from new app Coull some creating a new instance from ATCO object 121 00:08:55,010 --> 00:08:55,700 in here. 122 00:08:55,700 --> 00:08:57,500 I do want to have ideas. 123 00:08:57,770 --> 00:09:01,220 So what we have is just going to copy it here. 124 00:09:01,340 --> 00:09:04,920 I'm going to paste it and that's pretty much it. 125 00:09:05,390 --> 00:09:06,620 Now I do have everything. 126 00:09:06,620 --> 00:09:07,530 I do have the description. 127 00:09:07,530 --> 00:09:08,540 I do have the calories. 128 00:09:08,690 --> 00:09:09,890 I do have the quantities. 129 00:09:10,130 --> 00:09:12,850 I don't have just the idea in. 130 00:09:12,860 --> 00:09:17,270 So I can do it here and I can say, OK, I want to start with Idy zero. 131 00:09:17,480 --> 00:09:23,630 Don't worry about the idea now because yeah, the idea should be unique, but we will start with zero 132 00:09:23,630 --> 00:09:25,930 because that is a little bit longer. 133 00:09:25,930 --> 00:09:27,780 A lecture that I want to explain to you. 134 00:09:28,010 --> 00:09:33,200 So first I just want to add some calories, but we can copy the same thing. 135 00:09:33,830 --> 00:09:36,860 If the type is a burn, then we can say burn. 136 00:09:38,270 --> 00:09:40,250 We going to call that function constructor. 137 00:09:40,250 --> 00:09:40,540 Right? 138 00:09:40,760 --> 00:09:43,670 So we're calling the function constructor in this new gallery. 139 00:09:44,450 --> 00:09:46,480 We are making a new instance. 140 00:09:47,000 --> 00:09:50,150 So now we can add to our storage object. 141 00:09:51,050 --> 00:09:51,370 Right. 142 00:09:53,480 --> 00:10:00,670 So I'm going to pass as our burn and they we will add something to this object here. 143 00:10:00,860 --> 00:10:07,670 So how we can do this, we will use the push method because this is a theory, but how are we going 144 00:10:07,670 --> 00:10:08,440 to select it? 145 00:10:08,750 --> 00:10:15,290 So now I have new instance here, right in this new instance will have different values. 146 00:10:15,980 --> 00:10:19,580 But what I do now is just simply storage. 147 00:10:19,580 --> 00:10:22,190 I'm going to call the storage and look at this. 148 00:10:22,190 --> 00:10:27,470 I'm going to that structure storage all the old colorists, not categories. 149 00:10:28,520 --> 00:10:33,680 And based on the type that I have, it's going to be at Allburn. 150 00:10:34,250 --> 00:10:35,380 So how cool is this? 151 00:10:35,930 --> 00:10:40,220 So we select based on that I have Afterburn and that's where the type is there. 152 00:10:40,580 --> 00:10:42,290 So I can just simply push it. 153 00:10:44,510 --> 00:10:52,370 You can use this method push and I will add new Kalari right in this new Kaleri will contain whatever 154 00:10:52,370 --> 00:10:53,490 we're going to put here. 155 00:10:55,340 --> 00:10:56,060 Am I clear? 156 00:10:56,790 --> 00:10:57,590 Are we going to put here? 157 00:10:57,830 --> 00:11:01,910 It's going to be actually there right now. 158 00:11:02,750 --> 00:11:10,270 This push will add a new element at the end of the array, and that's pretty much it. 159 00:11:10,640 --> 00:11:13,840 Let's save it and let's see what's happening. 160 00:11:13,850 --> 00:11:23,710 So I'm going to refresh I'm going to add food when I say food one one and I'm going to add it in. 161 00:11:23,710 --> 00:11:24,740 Nothing is happening. 162 00:11:25,040 --> 00:11:25,520 Why? 163 00:11:25,760 --> 00:11:26,750 Because. 164 00:11:30,030 --> 00:11:36,360 And that is happening because we don't we are not bringing the result, we're not just bringing out 165 00:11:36,360 --> 00:11:37,360 these storage. 166 00:11:37,830 --> 00:11:44,550 So what I can do here, after where we add the calories, I'm going to use the same calories controller 167 00:11:44,700 --> 00:11:46,290 and I'm going to print out the result. 168 00:11:46,530 --> 00:11:51,600 So I hope now after every if everything is OK, so I'm going to say ice cream. 169 00:11:51,990 --> 00:11:53,940 I would like to see the output there. 170 00:11:54,720 --> 00:11:57,390 And still, it's not. 171 00:11:59,360 --> 00:12:01,490 Running here, what we do have. 172 00:12:04,700 --> 00:12:07,900 Because we need to control it, like that's why. 173 00:12:11,460 --> 00:12:17,680 Right, because we just returning something so here, I'm sorry, I'm going to be at again, so food 174 00:12:18,160 --> 00:12:18,700 one. 175 00:12:23,080 --> 00:12:31,240 And let's add it, and here it is, we do have these all calories in now if you go inside these object, 176 00:12:31,260 --> 00:12:35,920 we do have all calories object with add in Bernardy. 177 00:12:36,220 --> 00:12:39,400 Now, these Adoree look at this. 178 00:12:39,700 --> 00:12:43,050 If I go again in Adoree, I'm just going to go bigger here. 179 00:12:43,240 --> 00:12:49,120 I do have I did zero description food and calories one right now change to something else. 180 00:12:49,810 --> 00:12:53,250 Ice cream and hit enter. 181 00:12:53,800 --> 00:12:55,660 Now I'm going to see that one again. 182 00:12:55,660 --> 00:12:57,010 I have two items now. 183 00:12:58,300 --> 00:13:03,260 Again it will be description ice cream calories one because it didn't change the calories. 184 00:13:03,280 --> 00:13:04,420 Let's put something else. 185 00:13:05,080 --> 00:13:08,590 Let's put here, I don't know, hamburger. 186 00:13:09,610 --> 00:13:11,780 Not that I want to eat too many hamburgers. 187 00:13:11,840 --> 00:13:16,240 I click enter in what you need to scroll a little bit down in order to see this. 188 00:13:18,840 --> 00:13:26,070 So I do have food, ice cream and hamburger, but the negative for me is that I do have the same idea 189 00:13:26,070 --> 00:13:27,900 zero and that is not ideal. 190 00:13:27,930 --> 00:13:28,230 Right? 191 00:13:28,590 --> 00:13:32,430 And if I refresh, it's all gone right now. 192 00:13:33,360 --> 00:13:35,750 Tested out for air, for food. 193 00:13:35,970 --> 00:13:37,560 So food one. 194 00:13:39,060 --> 00:13:39,450 Right. 195 00:13:39,630 --> 00:13:42,450 And let's do exercise exercise. 196 00:13:42,450 --> 00:13:44,340 One hundred and fifty. 197 00:13:44,860 --> 00:13:47,510 Let's see both of the areas now contain something. 198 00:13:47,880 --> 00:13:48,690 So you go to the second. 199 00:13:48,750 --> 00:13:49,200 Here it is. 200 00:13:49,320 --> 00:13:59,910 Burn contains data and is going to be the ID zero X for the exercise calories and quantity in here. 201 00:13:59,910 --> 00:14:01,970 It will be for food, calories and quality. 202 00:14:02,250 --> 00:14:03,920 So I hope you are. 203 00:14:04,080 --> 00:14:06,100 You guys love this lecture. 204 00:14:06,130 --> 00:14:11,580 So what we did, we just print out the result and that result is just printed out the storage that we 205 00:14:11,580 --> 00:14:11,930 have. 206 00:14:12,210 --> 00:14:19,200 So what we did here, we grabbed whatever we have from the input from our form. 207 00:14:19,590 --> 00:14:26,430 We because we had grabbed that far from this point, we get form from input. 208 00:14:26,970 --> 00:14:32,190 We use that method to store the data here and that's why we can pass it to add calorie. 209 00:14:32,520 --> 00:14:34,650 Now you need to call this add calorie here. 210 00:14:34,680 --> 00:14:37,380 Otherwise it will not work. 211 00:14:37,620 --> 00:14:39,890 Right, that I'm trying to tell you. 212 00:14:40,290 --> 00:14:47,430 And here we are just basically saying, based on the type we are creating new instance of this function 213 00:14:47,430 --> 00:14:53,820 controller, if it's and we going to create add call, if it's within you, if it's burned, you're 214 00:14:53,820 --> 00:14:54,900 going to create one color. 215 00:14:55,080 --> 00:15:01,350 And after that, we use the storage all calories based on the type. 216 00:15:02,010 --> 00:15:02,430 Right. 217 00:15:03,270 --> 00:15:07,740 And we pushing this new calorie and that will push it back through. 218 00:15:08,610 --> 00:15:12,720 And as a last element is a new element at the end of the array. 219 00:15:12,930 --> 00:15:14,040 So I hope you enjoy. 220 00:15:14,370 --> 00:15:17,370 Now you learn that you can use only the object in here. 221 00:15:17,370 --> 00:15:18,210 You need to call it. 222 00:15:18,630 --> 00:15:21,050 If you use the object, it still will work, right? 223 00:15:21,360 --> 00:15:23,070 Still will work instead of doing this. 224 00:15:23,340 --> 00:15:29,670 But you need to take out this work and put it here, here if you want to work right in. 225 00:15:29,670 --> 00:15:31,710 Also here in. 226 00:15:31,710 --> 00:15:32,070 Yeah. 227 00:15:32,370 --> 00:15:33,810 The rest, you know how to do it. 228 00:15:34,020 --> 00:15:37,410 But I just prefer to store it in the variables and then use them. 229 00:15:37,410 --> 00:15:38,760 It's more cleaner like that. 230 00:15:39,150 --> 00:15:47,520 Or you can put the variables here like this and then you can use it here. 231 00:15:47,790 --> 00:15:48,600 So thank you very much. 232 00:15:48,600 --> 00:15:50,670 I hope you enjoy this and I will see you in the next one. 233 00:15:50,880 --> 00:15:51,870 Where are we going to work? 234 00:15:51,870 --> 00:16:00,270 How we can create a unique idea for every new entry, for every new Kalari entry for regardless regardless 235 00:16:00,270 --> 00:16:03,270 if it's for adding or burning new calories. 236 00:16:03,270 --> 00:16:03,570 Right. 237 00:16:03,810 --> 00:16:04,740 So thank you very much. 238 00:16:04,740 --> 00:16:05,850 And I see you in the next one.