OK.
Our setup looks pretty cool.
We are nicely using either method.
But before we can switch over to the front end.
Something that we need to do, and that is to manipulate the data, so whatever we have right now in
the stats.
That's why we set it up with Let.
And also add some defaults.
Now talk about the defaults in the next video.
In this video, simply what I want to do is not to return stats as an array like you just saw in a postman.
Instead, I want to return it as an object, and then each state's property value will be equal to account.
So how many items are there?
And just showcase that helped me navigate to the complete project for the components.
This is the case where we'll look for, I believe, the name or stats.
Let me see.
Yep.
Notice over here.
So I'm getting back this object with these values just because it's going to be easier for us on frontend.
And this is the video will utilize or douche, but I'm not going to go over the basics.
So if you need to refresh on the basics, please follow these links to Drake's Nuggets, where I cover
everything in greater detail when it comes to the reduced one.
Essentially, I want to iterate over array in the reduce we in the callback function, as well as what
we want to return.
In our case, that is going to be an object.
And then we pass in accumulator, essentially a parameter that represents what we return to, as well
as the current item since we're still iterating over the error.
Now, as I'm iterating, what I want to pull out is the ID and count, because remember, that's what
we have in those objects, and I write a way given on areas of tile.
And then let's go with accumulator.
So that's the object that I'm returning.
And then whatever is the value, whether that's spending the declined an interview, and let's set it
equal to the count.
So how many items and then we just return the object.
So let me go back to the jobs controller where I have show stats.
Like I said, I've purposely set it up with Let so we can go with the stats is equal to Stats Douche,
then what's passing the callback function?
And then let's say that from the reduced role, return an object and or pass an accumulator and current
item.
So that's the object we're returning, and that's the current item.
And let's do a little bit of magic here, where else that counts on underscore score is equal to title
and then count, and that's coming from each current item.
And then what's the Rider-Waite dynamically set up one object where I'll say accumulator title.
So that's going to be that decline into real spending, and then we'll set it equal to account now.
Always, always, always.
When you work with reduced, make sure that you return the accumulator, otherwise you'll have undefined.
So let's say that I won.
And now if I navigate back to the post instead of having stats as array, I should have it as an object.
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
values.