1 00:00:00,210 --> 00:00:00,900 Excellent work. 2 00:00:01,150 --> 00:00:03,600 Now let's deal with our calculations. 3 00:00:04,140 --> 00:00:10,820 So what I don't want to do, instead of iterating one more time over these repos, using the reduce 4 00:00:10,830 --> 00:00:18,490 or map or whatever, I would want to get of those stars for each and every item in the iteration where 5 00:00:18,510 --> 00:00:19,410 I'm getting the language. 6 00:00:19,990 --> 00:00:21,420 And there are two things to it. 7 00:00:21,780 --> 00:00:26,880 First, we need to check what is the property that is responsible for those stars. 8 00:00:27,000 --> 00:00:31,290 So that tells me how many stars the repo has. 9 00:00:31,320 --> 00:00:32,160 That's number one. 10 00:00:32,640 --> 00:00:36,420 And number two, we need to decide how we're gonna set up that object. 11 00:00:36,810 --> 00:00:41,400 Now, the property we're looking for is star gazers count. 12 00:00:41,790 --> 00:00:46,020 So that just tells me how many stars that particular report got. 13 00:00:46,620 --> 00:00:53,490 So if we take a look at the repos, I can see that I'm destruction the language, but I also could the 14 00:00:53,490 --> 00:00:55,070 structure stargazers count. 15 00:00:55,080 --> 00:00:55,440 Correct. 16 00:00:55,830 --> 00:01:02,390 So star gazers, gazers and land count PAGAD. 17 00:01:02,970 --> 00:01:06,720 So once we'd structured this particular property, what are we doing next? 18 00:01:06,810 --> 00:01:13,290 Well, remembered at first instance when we're setting up when we're saying if the language is not there, 19 00:01:13,470 --> 00:01:14,550 then we're creating one. 20 00:01:14,940 --> 00:01:21,120 Now, not only I could set up value as one, I could get that initial count because this is going to 21 00:01:21,120 --> 00:01:23,340 be the first time as we're setting up the language. 22 00:01:23,670 --> 00:01:29,160 So I'm just saying, yeah, get me how many stars this repoll has as well. 23 00:01:29,720 --> 00:01:32,550 And I'm going to set this up as a start property. 24 00:01:32,910 --> 00:01:38,400 So when I say stars and then star gazers count, that is my property. 25 00:01:38,910 --> 00:01:44,250 And then now when the language is already on object, what I would want to do. 26 00:01:44,730 --> 00:01:48,450 Well, now, not only I would want add Pelosse want to add the value. 27 00:01:48,780 --> 00:01:50,430 I also would want to update the stars. 28 00:01:50,460 --> 00:01:50,850 Correct. 29 00:01:51,240 --> 00:01:55,710 Because, of course, that new report does have some kind of stars, even if it's zero. 30 00:01:56,050 --> 00:01:59,370 So in here, we'll say total one language. 31 00:01:59,400 --> 00:02:00,450 So that stays the same. 32 00:02:00,810 --> 00:02:05,610 Then I'm looking for stars property, since that's the one that I'm looking for. 33 00:02:05,630 --> 00:02:06,930 I'm not looking for the value anymore. 34 00:02:07,320 --> 00:02:08,430 I'm looking for the stars. 35 00:02:08,770 --> 00:02:13,260 And this is going to be equal to plus whatever is in this iteration. 36 00:02:13,410 --> 00:02:15,690 So, again, same stargazers. 37 00:02:16,650 --> 00:02:17,340 Let's save that. 38 00:02:17,630 --> 00:02:22,030 And now, of course, we can just take a look before we change anything around in languages. 39 00:02:22,470 --> 00:02:23,940 So we're going to go with log on. 40 00:02:23,970 --> 00:02:26,250 That is going to be equal to eight languages. 41 00:02:26,730 --> 00:02:33,180 And you'll see that the only thing that has changed is the fact that we added that stars property in 42 00:02:33,180 --> 00:02:33,390 there. 43 00:02:33,600 --> 00:02:34,830 So we still have our object. 44 00:02:35,190 --> 00:02:42,000 Now, instead of just a label and the value the ones that the chart requires, we also have the stars. 45 00:02:42,360 --> 00:02:43,610 So we have four on 12. 46 00:02:43,910 --> 00:02:44,940 Forty six s. 47 00:02:45,090 --> 00:02:50,430 And then, for example, for JavaScript, we have three hundred and seventy six. 48 00:02:50,940 --> 00:02:58,080 And once we know that of course we can head back to a repost and change some stuff around where instead 49 00:02:58,080 --> 00:03:02,940 of overriding the languages, what I'm gonna do right now is I'm going to rename it. 50 00:03:03,420 --> 00:03:05,220 It's not going to be languages anymore. 51 00:03:05,670 --> 00:03:11,730 It is going to be cast and we'll call this most years, which of course, is going to signal that that 52 00:03:11,730 --> 00:03:13,230 is most use language. 53 00:03:13,530 --> 00:03:17,250 So instead of languages, instead of overriding languages like we did before. 54 00:03:17,730 --> 00:03:22,650 And also maybe used Konsta, we're here and we're still using the object values and all that. 55 00:03:23,010 --> 00:03:25,500 We're still passing in the languages object. 56 00:03:25,950 --> 00:03:28,400 And in this case, however, we're getting back most years. 57 00:03:28,770 --> 00:03:31,860 So, of course, in our chart, we would also need to change that. 58 00:03:32,430 --> 00:03:34,590 I'm going to say most used. 59 00:03:34,950 --> 00:03:38,600 So as far as the values, this shouldn't change for a first year. 60 00:03:39,110 --> 00:03:39,380 Ha. 61 00:03:39,390 --> 00:03:46,080 This allows us to set up a new variable where we're also gonna use the same language as object. 62 00:03:46,620 --> 00:03:50,580 We need to keep in mind that if we would have left the previous setup, then of course I would just 63 00:03:50,580 --> 00:03:55,140 be just using the languages that I'm getting back after these calculations. 64 00:03:55,440 --> 00:04:00,840 So let's add a common here and say most stars per language. 65 00:04:02,010 --> 00:04:03,630 Let's say most popular. 66 00:04:03,660 --> 00:04:04,470 So concept. 67 00:04:06,950 --> 00:04:10,690 Popular and that is equal to, again, object that values. 68 00:04:10,740 --> 00:04:12,170 So we're doing the same thing. 69 00:04:12,500 --> 00:04:15,320 Object that values and we're passing in the languages. 70 00:04:15,590 --> 00:04:18,350 So we're still getting the same object. 71 00:04:18,680 --> 00:04:23,120 And as always, we can SLOGGETT, just so we know that we're all are on the same page. 72 00:04:23,510 --> 00:04:29,960 So let's say most poor people are, shall we say that? 73 00:04:30,290 --> 00:04:32,930 Yeah, it is still an array with three items. 74 00:04:33,520 --> 00:04:36,380 And then label Joska value as well as the stars. 75 00:04:37,120 --> 00:04:41,660 Now, I would want to sort them based on the stars. 76 00:04:42,050 --> 00:04:43,210 So not on values. 77 00:04:43,610 --> 00:04:46,670 I would want to sort them based on stars. 78 00:04:47,140 --> 00:04:47,870 What do we do that? 79 00:04:48,380 --> 00:04:52,210 Well, we could again, chain and the same setup. 80 00:04:52,800 --> 00:04:56,210 Well, in this case, we're not looking for a value property. 81 00:04:56,570 --> 00:04:57,680 We're looking for the stars. 82 00:04:58,100 --> 00:05:06,050 So we chain dot sort then that is looking for a callback function on line in that callback function. 83 00:05:06,410 --> 00:05:08,120 We should decide how we would want to sort it. 84 00:05:08,670 --> 00:05:10,460 So again, I'm going to go with a B. 85 00:05:11,390 --> 00:05:12,830 So first line, I'm on the second item. 86 00:05:13,280 --> 00:05:19,590 And then just A return B stars minus a star as a start. 87 00:05:19,970 --> 00:05:25,770 So that's just gonna make sure that we have the values that start from Vegas. 88 00:05:26,150 --> 00:05:28,220 And then end up we the smallest one. 89 00:05:28,980 --> 00:05:33,420 Now, of course, I would just want to iterate and set up a new order. 90 00:05:33,700 --> 00:05:34,030 Why? 91 00:05:34,550 --> 00:05:41,420 Well, because if I'm looking at my most popular, the one thing that is missing that stars should be 92 00:05:41,420 --> 00:05:42,010 in the value. 93 00:05:42,020 --> 00:05:42,350 Correct. 94 00:05:42,800 --> 00:05:45,140 Because that's the one that my chart is looking for. 95 00:05:45,680 --> 00:05:47,150 Chart is not looking for the stars. 96 00:05:47,540 --> 00:05:49,460 Chart is looking for a value property. 97 00:05:50,060 --> 00:05:53,360 So what we could do is we could just flip them. 98 00:05:53,630 --> 00:05:59,300 So whatever values we have for the actual value will assign them to our stars. 99 00:05:59,810 --> 00:06:02,660 And the way we do that is by using the map. 100 00:06:03,870 --> 00:06:10,740 Then on each and every iteration, I can access the item, of course, some will say item here and then 101 00:06:10,920 --> 00:06:14,850 from the iteration, I would still want to return the object. 102 00:06:15,150 --> 00:06:15,810 Same object. 103 00:06:15,870 --> 00:06:17,790 I would want to copy all the values. 104 00:06:17,820 --> 00:06:23,450 However, I will overwrite the value property with item that stars. 105 00:06:24,000 --> 00:06:29,820 So I'm taking the value of this property and just assigning it to a value property. 106 00:06:29,910 --> 00:06:30,270 Why? 107 00:06:30,750 --> 00:06:32,910 Because that's the one that the chart is looking for. 108 00:06:33,360 --> 00:06:35,640 That's why we'll return from the map. 109 00:06:36,240 --> 00:06:42,930 And now, of course, see in a console that we have the values for hand twelve, then three seventy 110 00:06:42,930 --> 00:06:43,320 six. 111 00:06:43,560 --> 00:06:44,580 And then, of course, 34. 112 00:06:45,090 --> 00:06:46,270 Now you might be wondering, OK. 113 00:06:46,440 --> 00:06:48,720 But our value for the language disappeared. 114 00:06:49,150 --> 00:06:49,950 Well, we don't need that. 115 00:06:50,460 --> 00:06:51,700 I only need the stars. 116 00:06:52,260 --> 00:06:59,610 I just added it to a first iteration because I didn't see the point of setting up a new reduced function. 117 00:07:00,090 --> 00:07:03,030 But the one that I'm looking for is the stars. 118 00:07:03,270 --> 00:07:09,030 Now, I cannot really rename the stars because my chart is looking for a value property. 119 00:07:09,680 --> 00:07:14,760 And the last thing that I would want is, again, to make sure that I only have five languages. 120 00:07:14,790 --> 00:07:18,570 So I'm gonna go to slice zero and then five. 121 00:07:19,490 --> 00:07:25,610 And now, of course, we can delete the console, log online instead of chart data. 122 00:07:26,210 --> 00:07:29,780 That's past our most popular Mac show. 123 00:07:30,410 --> 00:07:34,190 And now, of course, I can get her off my inspect and there it is. 124 00:07:34,610 --> 00:07:41,020 Now, not only we show how many reposts are with Joss script or she says, Orridge, the Amelle. 125 00:07:41,510 --> 00:07:46,710 We also show the combined value of the star's photos languages. 126 00:07:47,210 --> 00:07:54,710 So, for example, all the repos that have the language of success have combined total of 400 to outsource 127 00:07:54,860 --> 00:07:57,050 jobs, compressed three hundred seventy six. 128 00:07:57,450 --> 00:07:59,600 And then all has only 34.