1
00:00:00,330 --> 00:00:00,630
OK.

2
00:00:01,080 --> 00:00:03,000
Our setup looks pretty cool.

3
00:00:03,660 --> 00:00:06,030
We are nicely using either method.

4
00:00:06,420 --> 00:00:08,970
But before we can switch over to the front end.

5
00:00:10,260 --> 00:00:17,740
Something that we need to do, and that is to manipulate the data, so whatever we have right now in

6
00:00:17,740 --> 00:00:18,290
the stats.

7
00:00:18,310 --> 00:00:19,810
That's why we set it up with Let.

8
00:00:20,200 --> 00:00:21,930
And also add some defaults.

9
00:00:21,940 --> 00:00:24,130
Now talk about the defaults in the next video.

10
00:00:24,520 --> 00:00:31,900
In this video, simply what I want to do is not to return stats as an array like you just saw in a postman.

11
00:00:32,290 --> 00:00:41,140
Instead, I want to return it as an object, and then each state's property value will be equal to account.

12
00:00:41,800 --> 00:00:43,930
So how many items are there?

13
00:00:44,230 --> 00:00:51,010
And just showcase that helped me navigate to the complete project for the components.

14
00:00:51,640 --> 00:00:56,950
This is the case where we'll look for, I believe, the name or stats.

15
00:00:56,980 --> 00:00:57,570
Let me see.

16
00:00:57,580 --> 00:00:57,810
Yep.

17
00:00:58,240 --> 00:00:58,980
Notice over here.

18
00:00:59,170 --> 00:01:05,560
So I'm getting back this object with these values just because it's going to be easier for us on frontend.

19
00:01:06,330 --> 00:01:12,370
And this is the video will utilize or douche, but I'm not going to go over the basics.

20
00:01:12,370 --> 00:01:18,820
So if you need to refresh on the basics, please follow these links to Drake's Nuggets, where I cover

21
00:01:18,820 --> 00:01:22,780
everything in greater detail when it comes to the reduced one.

22
00:01:23,650 --> 00:01:29,470
Essentially, I want to iterate over array in the reduce we in the callback function, as well as what

23
00:01:29,470 --> 00:01:30,220
we want to return.

24
00:01:30,220 --> 00:01:32,230
In our case, that is going to be an object.

25
00:01:32,590 --> 00:01:39,400
And then we pass in accumulator, essentially a parameter that represents what we return to, as well

26
00:01:39,400 --> 00:01:42,140
as the current item since we're still iterating over the error.

27
00:01:42,580 --> 00:01:48,730
Now, as I'm iterating, what I want to pull out is the ID and count, because remember, that's what

28
00:01:48,730 --> 00:01:52,510
we have in those objects, and I write a way given on areas of tile.

29
00:01:52,960 --> 00:01:54,730
And then let's go with accumulator.

30
00:01:55,090 --> 00:01:56,860
So that's the object that I'm returning.

31
00:01:57,130 --> 00:02:04,030
And then whatever is the value, whether that's spending the declined an interview, and let's set it

32
00:02:04,030 --> 00:02:05,110
equal to the count.

33
00:02:05,140 --> 00:02:08,440
So how many items and then we just return the object.

34
00:02:08,919 --> 00:02:13,090
So let me go back to the jobs controller where I have show stats.

35
00:02:13,090 --> 00:02:18,730
Like I said, I've purposely set it up with Let so we can go with the stats is equal to Stats Douche,

36
00:02:19,360 --> 00:02:21,400
then what's passing the callback function?

37
00:02:22,300 --> 00:02:28,390
And then let's say that from the reduced role, return an object and or pass an accumulator and current

38
00:02:28,390 --> 00:02:28,840
item.

39
00:02:29,410 --> 00:02:32,800
So that's the object we're returning, and that's the current item.

40
00:02:33,240 --> 00:02:39,760
And let's do a little bit of magic here, where else that counts on underscore score is equal to title

41
00:02:40,000 --> 00:02:44,590
and then count, and that's coming from each current item.

42
00:02:45,040 --> 00:02:50,560
And then what's the Rider-Waite dynamically set up one object where I'll say accumulator title.

43
00:02:51,340 --> 00:02:56,620
So that's going to be that decline into real spending, and then we'll set it equal to account now.

44
00:02:56,620 --> 00:02:57,910
Always, always, always.

45
00:02:57,910 --> 00:03:04,000
When you work with reduced, make sure that you return the accumulator, otherwise you'll have undefined.

46
00:03:04,030 --> 00:03:05,170
So let's say that I won.

47
00:03:05,470 --> 00:03:13,180
And now if I navigate back to the post instead of having stats as array, I should have it as an object.

48
00:03:13,530 --> 00:03:19,870
And if you see the same thing, we are in good shape and now we're ready to move on and set up the default

49
00:03:19,870 --> 00:03:20,260
values.

