All right.
We can remove the item.
Now let's see how we can increase the amount and for increased demand we're going to start by assigning
to a variable so we can say cost.
I'm gonna call this new card and then again we're gonna spread out our card values then we're gonna
run map methadone them.
So we have the array so we can run the math method and then I would like to access each and every item
and not set up functionality what we would want to do.
So I would want to check whether the I.D. that I'm getting from the increased amount matches that of
the item.
Again we're just iterating over the array and then we're just checking if the I.D. matches that of the
item I.D. even the item I.D. matches.
Then we're going to update the amount property on that item if the item does not have the same I.D.
then we're just gonna return whatever properties the item has.
So the way is going to look like when I say return item I.D. equals to Eddie.
So this is the place where we're checking and then we're saying if it matches if the matches then spread
out all the properties that item has and then if you'd want to update one of the properties we just
need to rewrite it.
So we have item and then we're overriding the amount so amount is already returned.
Since we're spreading out the properties but then we can override that and we can say that the amount
right now is gonna be equal to our item amount and then plus one since.
Of course we are adding one item notice.
Again we are spreading out all the properties that item has starting from the 80s and all the way to
image and then since we would like to override the amount property that's where we set up a month.
So that's gonna be the new value then we're grabbing the old value.
So Item Amount.
And then we're just adding 1 that is of course because we are increasing the amount.
Now if the item I.D. does not match then we can just say spread out all the properties that itemize.
And essentially we're just gonna get a new card that will have one of the items with increased value
and then eventually we're just gonna have a set card said card and we're gonna pass in the new card
again.
I could have written this.
Of course even shorter could have set up the functionally right here within a set card but I didn't
want to confuse you too much.
That's the reason why we set up a separate new card variable.
We're almost done.
We just need to head over to card item then like we had with remove item we're going to have increase
crease increase amount amount and then of course we would want to run it.
So when we have the angle up means increasing.
So let's run increase amount.
And then again let's pass in the idea that each and every card item has and let's say we can add over
and we're going to try to increase this guy.
And sure enough we do.
And also notice how each and every time we update the state value or total also changes in the same
work would remove if we remove the item we right away are calculating the values.
And since I can see that my functionality works now we can head over and start working on the decreased
amount.