1 00:00:00,270 --> 00:00:00,960 All right. 2 00:00:00,960 --> 00:00:02,260 We can remove the item. 3 00:00:02,310 --> 00:00:08,310 Now let's see how we can increase the amount and for increased demand we're going to start by assigning 4 00:00:08,310 --> 00:00:11,150 to a variable so we can say cost. 5 00:00:11,270 --> 00:00:17,110 I'm gonna call this new card and then again we're gonna spread out our card values then we're gonna 6 00:00:17,130 --> 00:00:19,180 run map methadone them. 7 00:00:19,290 --> 00:00:24,960 So we have the array so we can run the math method and then I would like to access each and every item 8 00:00:25,270 --> 00:00:27,990 and not set up functionality what we would want to do. 9 00:00:28,530 --> 00:00:36,540 So I would want to check whether the I.D. that I'm getting from the increased amount matches that of 10 00:00:36,540 --> 00:00:37,860 the item. 11 00:00:38,070 --> 00:00:44,580 Again we're just iterating over the array and then we're just checking if the I.D. matches that of the 12 00:00:44,580 --> 00:00:47,560 item I.D. even the item I.D. matches. 13 00:00:47,730 --> 00:00:53,890 Then we're going to update the amount property on that item if the item does not have the same I.D. 14 00:00:54,260 --> 00:00:58,560 then we're just gonna return whatever properties the item has. 15 00:00:58,560 --> 00:01:04,280 So the way is going to look like when I say return item I.D. equals to Eddie. 16 00:01:04,320 --> 00:01:11,430 So this is the place where we're checking and then we're saying if it matches if the matches then spread 17 00:01:11,430 --> 00:01:17,460 out all the properties that item has and then if you'd want to update one of the properties we just 18 00:01:17,460 --> 00:01:18,510 need to rewrite it. 19 00:01:18,930 --> 00:01:24,680 So we have item and then we're overriding the amount so amount is already returned. 20 00:01:24,780 --> 00:01:30,420 Since we're spreading out the properties but then we can override that and we can say that the amount 21 00:01:30,420 --> 00:01:35,450 right now is gonna be equal to our item amount and then plus one since. 22 00:01:35,460 --> 00:01:38,790 Of course we are adding one item notice. 23 00:01:38,790 --> 00:01:44,460 Again we are spreading out all the properties that item has starting from the 80s and all the way to 24 00:01:44,490 --> 00:01:50,310 image and then since we would like to override the amount property that's where we set up a month. 25 00:01:50,310 --> 00:01:53,820 So that's gonna be the new value then we're grabbing the old value. 26 00:01:53,850 --> 00:01:55,120 So Item Amount. 27 00:01:55,290 --> 00:01:59,970 And then we're just adding 1 that is of course because we are increasing the amount. 28 00:02:00,360 --> 00:02:07,820 Now if the item I.D. does not match then we can just say spread out all the properties that itemize. 29 00:02:07,980 --> 00:02:14,460 And essentially we're just gonna get a new card that will have one of the items with increased value 30 00:02:14,820 --> 00:02:21,480 and then eventually we're just gonna have a set card said card and we're gonna pass in the new card 31 00:02:21,880 --> 00:02:22,680 again. 32 00:02:22,860 --> 00:02:24,060 I could have written this. 33 00:02:24,060 --> 00:02:29,820 Of course even shorter could have set up the functionally right here within a set card but I didn't 34 00:02:29,820 --> 00:02:31,460 want to confuse you too much. 35 00:02:31,530 --> 00:02:35,360 That's the reason why we set up a separate new card variable. 36 00:02:35,400 --> 00:02:36,330 We're almost done. 37 00:02:36,330 --> 00:02:42,780 We just need to head over to card item then like we had with remove item we're going to have increase 38 00:02:43,680 --> 00:02:50,430 crease increase amount amount and then of course we would want to run it. 39 00:02:50,450 --> 00:02:55,790 So when we have the angle up means increasing. 40 00:02:55,790 --> 00:02:57,950 So let's run increase amount. 41 00:02:57,950 --> 00:03:04,820 And then again let's pass in the idea that each and every card item has and let's say we can add over 42 00:03:05,200 --> 00:03:06,740 and we're going to try to increase this guy. 43 00:03:07,100 --> 00:03:08,310 And sure enough we do. 44 00:03:08,450 --> 00:03:14,900 And also notice how each and every time we update the state value or total also changes in the same 45 00:03:14,900 --> 00:03:19,670 work would remove if we remove the item we right away are calculating the values. 46 00:03:19,790 --> 00:03:26,270 And since I can see that my functionality works now we can head over and start working on the decreased 47 00:03:26,420 --> 00:03:26,810 amount.