Excellent work.
Now let's deal with our calculations.
So what I don't want to do, instead of iterating one more time over these repos, using the reduce
or map or whatever, I would want to get of those stars for each and every item in the iteration where
I'm getting the language.
And there are two things to it.
First, we need to check what is the property that is responsible for those stars.
So that tells me how many stars the repo has.
That's number one.
And number two, we need to decide how we're gonna set up that object.
Now, the property we're looking for is star gazers count.
So that just tells me how many stars that particular report got.
So if we take a look at the repos, I can see that I'm destruction the language, but I also could the
structure stargazers count.
Correct.
So star gazers, gazers and land count PAGAD.
So once we'd structured this particular property, what are we doing next?
Well, remembered at first instance when we're setting up when we're saying if the language is not there,
then we're creating one.
Now, not only I could set up value as one, I could get that initial count because this is going to
be the first time as we're setting up the language.
So I'm just saying, yeah, get me how many stars this repoll has as well.
And I'm going to set this up as a start property.
So when I say stars and then star gazers count, that is my property.
And then now when the language is already on object, what I would want to do.
Well, now, not only I would want add Pelosse want to add the value.
I also would want to update the stars.
Correct.
Because, of course, that new report does have some kind of stars, even if it's zero.
So in here, we'll say total one language.
So that stays the same.
Then I'm looking for stars property, since that's the one that I'm looking for.
I'm not looking for the value anymore.
I'm looking for the stars.
And this is going to be equal to plus whatever is in this iteration.
So, again, same stargazers.
Let's save that.
And now, of course, we can just take a look before we change anything around in languages.
So we're going to go with log on.
That is going to be equal to eight languages.
And you'll see that the only thing that has changed is the fact that we added that stars property in
there.
So we still have our object.
Now, instead of just a label and the value the ones that the chart requires, we also have the stars.
So we have four on 12.
Forty six s.
And then, for example, for JavaScript, we have three hundred and seventy six.
And once we know that of course we can head back to a repost and change some stuff around where instead
of overriding the languages, what I'm gonna do right now is I'm going to rename it.
It's not going to be languages anymore.
It is going to be cast and we'll call this most years, which of course, is going to signal that that
is most use language.
So instead of languages, instead of overriding languages like we did before.
And also maybe used Konsta, we're here and we're still using the object values and all that.
We're still passing in the languages object.
And in this case, however, we're getting back most years.
So, of course, in our chart, we would also need to change that.
I'm going to say most used.
So as far as the values, this shouldn't change for a first year.
Ha.
This allows us to set up a new variable where we're also gonna use the same language as object.
We need to keep in mind that if we would have left the previous setup, then of course I would just
be just using the languages that I'm getting back after these calculations.
So let's add a common here and say most stars per language.
Let's say most popular.
So concept.
Popular and that is equal to, again, object that values.
So we're doing the same thing.
Object that values and we're passing in the languages.
So we're still getting the same object.
And as always, we can SLOGGETT, just so we know that we're all are on the same page.
So let's say most poor people are, shall we say that?
Yeah, it is still an array with three items.
And then label Joska value as well as the stars.
Now, I would want to sort them based on the stars.
So not on values.
I would want to sort them based on stars.
What do we do that?
Well, we could again, chain and the same setup.
Well, in this case, we're not looking for a value property.
We're looking for the stars.
So we chain dot sort then that is looking for a callback function on line in that callback function.
We should decide how we would want to sort it.
So again, I'm going to go with a B.
So first line, I'm on the second item.
And then just A return B stars minus a star as a start.
So that's just gonna make sure that we have the values that start from Vegas.
And then end up we the smallest one.
Now, of course, I would just want to iterate and set up a new order.
Why?
Well, because if I'm looking at my most popular, the one thing that is missing that stars should be
in the value.
Correct.
Because that's the one that my chart is looking for.
Chart is not looking for the stars.
Chart is looking for a value property.
So what we could do is we could just flip them.
So whatever values we have for the actual value will assign them to our stars.
And the way we do that is by using the map.
Then on each and every iteration, I can access the item, of course, some will say item here and then
from the iteration, I would still want to return the object.
Same object.
I would want to copy all the values.
However, I will overwrite the value property with item that stars.
So I'm taking the value of this property and just assigning it to a value property.
Why?
Because that's the one that the chart is looking for.
That's why we'll return from the map.
And now, of course, see in a console that we have the values for hand twelve, then three seventy
six.
And then, of course, 34.
Now you might be wondering, OK.
But our value for the language disappeared.
Well, we don't need that.
I only need the stars.
I just added it to a first iteration because I didn't see the point of setting up a new reduced function.
But the one that I'm looking for is the stars.
Now, I cannot really rename the stars because my chart is looking for a value property.
And the last thing that I would want is, again, to make sure that I only have five languages.
So I'm gonna go to slice zero and then five.
And now, of course, we can delete the console, log online instead of chart data.
That's past our most popular Mac show.
And now, of course, I can get her off my inspect and there it is.
Now, not only we show how many reposts are with Joss script or she says, Orridge, the Amelle.
We also show the combined value of the star's photos languages.
So, for example, all the repos that have the language of success have combined total of 400 to outsource
jobs, compressed three hundred seventy six.
And then all has only 34.