Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
1
00:00:01,260 --> 00:00:03,820
Welcome to the first coding challenge
2
2
00:00:03,820 --> 00:00:05,540
of this section.
3
3
00:00:05,540 --> 00:00:07,280
And as you can imagine,
4
4
00:00:07,280 --> 00:00:10,283
this one is gonna be all about functions.
5
5
00:00:12,190 --> 00:00:14,580
And we're back to the two gymnastic teams
6
6
00:00:14,580 --> 00:00:18,660
from the previous section, the Dolphins and Koalas.
7
7
00:00:18,660 --> 00:00:21,620
And now there is a new gymnastics discipline
8
8
00:00:21,620 --> 00:00:24,400
which works in a bit different way.
9
9
00:00:24,400 --> 00:00:26,130
So now in this new discipline,
10
10
00:00:26,130 --> 00:00:28,560
each team competes three times
11
11
00:00:28,560 --> 00:00:32,630
and then the average of the three scores is calculated,
12
12
00:00:32,630 --> 00:00:36,010
so each team will get one average score.
13
13
00:00:36,010 --> 00:00:38,040
And then a team only wins
14
14
00:00:38,040 --> 00:00:40,910
if it has at least doubled the average score
15
15
00:00:40,910 --> 00:00:45,060
of the other team and otherwise no team wins.
16
16
00:00:45,060 --> 00:00:48,810
So sounds pretty simple, I hope.
17
17
00:00:48,810 --> 00:00:53,120
And let's take a look at your tasks now.
18
18
00:00:53,120 --> 00:00:55,740
So first create an arrow function
19
19
00:00:55,740 --> 00:00:59,210
called calcAverage which calculates the average
20
20
00:00:59,210 --> 00:01:01,210
of three scores.
21
21
00:01:01,210 --> 00:01:03,640
And actually this calcAverage function
22
22
00:01:03,640 --> 00:01:07,670
should be able to calculate the average of any three values.
23
23
00:01:07,670 --> 00:01:10,610
So of course, the values don't have to be scores.
24
24
00:01:10,610 --> 00:01:14,440
Any random numbers will work just the same.
25
25
00:01:14,440 --> 00:01:16,730
So this is basically a generic function
26
26
00:01:16,730 --> 00:01:20,230
just to calculate the average of three values.
27
27
00:01:20,230 --> 00:01:21,960
Then use that function
28
28
00:01:21,960 --> 00:01:24,970
to calculate the average for both teams.
29
29
00:01:24,970 --> 00:01:26,300
And again, down here,
30
30
00:01:26,300 --> 00:01:29,063
you have the test data that you can use.
31
31
00:01:30,030 --> 00:01:32,660
Create a function called checkWiner
32
32
00:01:32,660 --> 00:01:36,990
which takes the average score of each team as parameters,
33
33
00:01:36,990 --> 00:01:37,970
and these parameters
34
34
00:01:37,970 --> 00:01:42,230
should be called average Dolphins here and average Koalas.
35
35
00:01:42,230 --> 00:01:45,480
And then based on these two average scores,
36
36
00:01:45,480 --> 00:01:48,090
the function will log the winner to the console
37
37
00:01:48,090 --> 00:01:51,060
together with the victory points.
38
38
00:01:51,060 --> 00:01:54,430
And that of course needs to happen according to the rule
39
39
00:01:54,430 --> 00:01:56,410
that I just explained before.
40
40
00:01:56,410 --> 00:01:57,880
So a team only wins
41
41
00:01:57,880 --> 00:02:00,730
if it has at least doubled the average score
42
42
00:02:00,730 --> 00:02:01,970
of the other team,
43
43
00:02:01,970 --> 00:02:04,290
and otherwise no team wins.
44
44
00:02:04,290 --> 00:02:06,560
So you need to check for that condition
45
45
00:02:06,560 --> 00:02:08,940
in order to print which team wins,
46
46
00:02:08,940 --> 00:02:12,350
and in some cases, no team might win at all.
47
47
00:02:12,350 --> 00:02:15,090
So you need to account for that as well.
48
48
00:02:15,090 --> 00:02:19,210
So here in point three you write to checkWiner function
49
49
00:02:19,210 --> 00:02:22,130
and then a number four you will use.
50
50
00:02:22,130 --> 00:02:24,930
So basically you will call the checkWinner function
51
51
00:02:24,930 --> 00:02:27,110
in order to determine the winner
52
52
00:02:27,110 --> 00:02:30,673
for both to test data one and test data two.
53
53
00:02:33,050 --> 00:02:34,840
I have some hints again,
54
54
00:02:34,840 --> 00:02:37,970
but if you want to try it on your own without the hints
55
55
00:02:37,970 --> 00:02:40,360
then just past the video right now.
56
56
00:02:40,360 --> 00:02:41,830
But if you need to hints
57
57
00:02:41,830 --> 00:02:43,883
then well, here they go.
58
58
00:02:44,880 --> 00:02:47,470
So this one is probably pretty obvious
59
59
00:02:47,470 --> 00:02:50,980
which is to calculate the average of three values,
60
60
00:02:50,980 --> 00:02:54,410
add them altogether and divide by three.
61
61
00:02:54,410 --> 00:02:57,650
But the second one here is a little bit more important
62
62
00:02:57,650 --> 00:03:01,380
and maybe more difficult for you to figure out on your own.
63
63
00:03:01,380 --> 00:03:06,280
So to check if number A is at least double number B,
64
64
00:03:06,280 --> 00:03:09,570
what you need to check is if A
65
65
00:03:09,570 --> 00:03:13,003
is greater or equal two times B.
66
66
00:03:14,746 --> 00:03:16,210
And so this is what you will use
67
67
00:03:16,210 --> 00:03:18,323
with the teams average scores.
68
68
00:03:19,210 --> 00:03:22,610
So it's important to keep this one in mind
69
69
00:03:22,610 --> 00:03:24,260
because of this rule,
70
70
00:03:24,260 --> 00:03:28,200
that the team only wins when it has doubled average score
71
71
00:03:28,200 --> 00:03:29,363
of the other team.
72
72
00:03:31,400 --> 00:03:33,630
Now, please make really sure
73
73
00:03:33,630 --> 00:03:36,730
that you understood everything I showed you about functions
74
74
00:03:36,730 --> 00:03:39,140
before you attempt this challenge.
75
75
00:03:39,140 --> 00:03:42,390
Because this one is not so straight forward,
76
76
00:03:42,390 --> 00:03:45,570
and so I don't want you to get frustrated.
77
77
00:03:45,570 --> 00:03:48,830
So again, please really make sure you understand functions
78
78
00:03:48,830 --> 00:03:52,400
and only then attempt to do this challenge.
79
79
00:03:52,400 --> 00:03:54,530
But if you feel that you're ready,
80
80
00:03:54,530 --> 00:03:56,230
then just pause the video now
81
81
00:03:56,230 --> 00:03:58,683
and good luck with this challenge.
82
82
00:04:03,330 --> 00:04:07,240
Let me show you my solution to this challenge,
83
83
00:04:07,240 --> 00:04:11,120
which I hope of course you were able to do on your own.
84
84
00:04:11,120 --> 00:04:12,280
So I'm gonna start
85
85
00:04:12,280 --> 00:04:15,963
with the calcAverage function as a number one,
86
86
00:04:16,940 --> 00:04:19,670
and remember that this should be an arrow function
87
87
00:04:19,670 --> 00:04:22,040
and it will receive three values
88
88
00:04:22,040 --> 00:04:24,510
so that it can calculate the average
89
89
00:04:24,510 --> 00:04:26,420
of these three numbers.
90
90
00:04:26,420 --> 00:04:28,220
And here I'm actually just gonna call
91
91
00:04:28,220 --> 00:04:32,330
the three numbers, A, B and C,
92
92
00:04:32,330 --> 00:04:35,480
because again, this is supposed to be just
93
93
00:04:35,480 --> 00:04:38,740
a generic function which can calculate averages
94
94
00:04:38,740 --> 00:04:40,550
of any three numbers,
95
95
00:04:40,550 --> 00:04:42,640
it doesn't have to be any scores.
96
96
00:04:42,640 --> 00:04:46,470
And so A, B, C are just generic variable names.
97
97
00:04:46,470 --> 00:04:48,860
But of course it's totally okay
98
98
00:04:48,860 --> 00:04:51,873
if you used more specific variable names.
99
99
00:04:53,640 --> 00:04:55,970
So adding all the three numbers together
100
100
00:04:55,970 --> 00:04:58,140
and then dividing by three.
101
101
00:04:58,140 --> 00:04:59,640
So this one is nothing new,
102
102
00:04:59,640 --> 00:05:02,330
this was just to basically test your knowledge
103
103
00:05:02,330 --> 00:05:05,170
of the syntax of the arrow function.
104
104
00:05:05,170 --> 00:05:06,920
So what's important to notice here
105
105
00:05:06,920 --> 00:05:08,770
is that we need to parenthesis here
106
106
00:05:08,770 --> 00:05:11,400
because we have multiple parameters,
107
107
00:05:11,400 --> 00:05:14,640
but then here, we only really have this line of code.
108
108
00:05:14,640 --> 00:05:18,570
And so therefore we don't need to even write the return.
109
109
00:05:18,570 --> 00:05:22,490
This value gets automatically returned from the function.
110
110
00:05:22,490 --> 00:05:24,010
And now let's just test it out
111
111
00:05:24,010 --> 00:05:26,600
before we move any further.
112
112
00:05:26,600 --> 00:05:31,600
So calcAverage and then let's just use some random numbers
113
113
00:05:32,190 --> 00:05:37,190
because here we know that this is supposed to be four.
114
114
00:05:37,966 --> 00:05:39,890
So we have three, four, five.
115
115
00:05:39,890 --> 00:05:41,480
And so the middle one here
116
116
00:05:42,390 --> 00:05:44,823
is the average between these three.
117
117
00:05:46,410 --> 00:05:50,430
And indeed it is, and so we know that our function works.
118
118
00:05:50,430 --> 00:05:53,370
And so we can move on to point number two,
119
119
00:05:53,370 --> 00:05:54,960
which is to use the function
120
120
00:05:54,960 --> 00:05:57,713
to calculate the average for both teams.
121
121
00:06:02,252 --> 00:06:04,580
So let's say score Dolphins
122
122
00:06:07,040 --> 00:06:08,580
is equal to calcAverage
123
123
00:06:09,970 --> 00:06:12,150
and now we pass into specific arguments
124
124
00:06:12,150 --> 00:06:15,760
for the three parameters, A, B and C.
125
125
00:06:15,760 --> 00:06:18,700
And so for test data one, which is this,
126
126
00:06:18,700 --> 00:06:22,170
so let me actually write that here, test one.
127
127
00:06:22,170 --> 00:06:27,170
So for the Dolphins, we pass into values 44, 23 and 71.
128
128
00:06:30,370 --> 00:06:34,020
Then for the Koalas, it works the same way.
129
129
00:06:34,020 --> 00:06:37,673
So score Koalas equals calcAverage.
130
130
00:06:40,403 --> 00:06:42,957
And now we have 65, 54 and 49.
131
131
00:06:47,150 --> 00:06:49,403
Nice reusable function right here.
132
132
00:06:50,460 --> 00:06:52,060
And so having this function,
133
133
00:06:52,060 --> 00:06:55,070
we don't need to calculate it here manually
134
134
00:06:55,070 --> 00:06:56,250
every single time.
135
135
00:06:56,250 --> 00:06:57,913
So that's really great.
136
136
00:06:59,170 --> 00:07:02,660
We can really appreciate the fact that again,
137
137
00:07:02,660 --> 00:07:06,690
a function is really like a machine in some sense.
138
138
00:07:06,690 --> 00:07:09,330
So it doesn't care where the inputs come from
139
139
00:07:09,330 --> 00:07:11,170
and where they go.
140
140
00:07:11,170 --> 00:07:14,740
All it does is to calculate the average of three numbers,
141
141
00:07:14,740 --> 00:07:18,030
no matter if it's scores or heights of people
142
142
00:07:18,030 --> 00:07:20,710
or money or whatever it is.
143
143
00:07:20,710 --> 00:07:23,340
So this function really is kind of isolated
144
144
00:07:23,340 --> 00:07:25,520
from the rest of the code here.
145
145
00:07:25,520 --> 00:07:28,500
It's a standalone function that we can then use
146
146
00:07:28,500 --> 00:07:30,830
for our own purposes.
147
147
00:07:30,830 --> 00:07:33,030
And that might sound pretty obvious,
148
148
00:07:33,030 --> 00:07:36,170
but it's actually important that you really internalize
149
149
00:07:36,170 --> 00:07:38,500
this aspect of functions.
150
150
00:07:38,500 --> 00:07:40,510
Only then can you really start
151
151
00:07:40,510 --> 00:07:45,180
to see the potential for functions everywhere in your code.
152
152
00:07:45,180 --> 00:07:47,990
Anyway, with that being said,
153
153
00:07:47,990 --> 00:07:51,280
let's now log these values to the console
154
154
00:07:53,280 --> 00:07:55,800
'cause I always like to see what I'm doing.
155
155
00:07:55,800 --> 00:07:58,173
So this part is of course not mandatory,
156
156
00:07:59,110 --> 00:08:01,910
but it's also nice to be able to know the scores
157
157
00:08:01,910 --> 00:08:03,840
so that we know if the logic
158
158
00:08:03,840 --> 00:08:06,963
that we're gonna implement next is working correctly.
159
159
00:08:07,820 --> 00:08:10,530
So we see that in this case,
160
160
00:08:10,530 --> 00:08:13,280
the Koalas have a score that is higher
161
161
00:08:13,280 --> 00:08:16,740
than one of the Dolphins but it's not double.
162
162
00:08:16,740 --> 00:08:19,330
And so we already know that in this case
163
163
00:08:19,330 --> 00:08:22,260
no team should be able to win,
164
164
00:08:22,260 --> 00:08:25,253
but let's not actually implement that functionality.
165
165
00:08:26,220 --> 00:08:29,120
So that's the function checkWinner.
166
166
00:08:29,120 --> 00:08:31,320
And so it takes the average Dolphins
167
167
00:08:31,320 --> 00:08:33,980
and average Koalas parameters
168
168
00:08:35,850 --> 00:08:38,280
and then it locks the winner to the console.
169
169
00:08:38,280 --> 00:08:40,033
So let's do that.
170
170
00:08:41,320 --> 00:08:42,910
And what's more, it's no problem
171
171
00:08:42,910 --> 00:08:44,803
if you did this differently.
172
172
00:08:46,930 --> 00:08:49,623
If you made it work then it's great.
173
173
00:08:51,150 --> 00:08:56,150
So average Dolphins and average Koalas.
174
174
00:08:59,460 --> 00:09:01,630
And now all they need to do is to check
175
175
00:09:01,630 --> 00:09:04,880
whether the Dolphins won or the Koalas won
176
176
00:09:04,880 --> 00:09:07,910
or if no one won basically.
177
177
00:09:07,910 --> 00:09:10,660
So when do the Dolphins win?
178
178
00:09:10,660 --> 00:09:11,770
Well, they win
179
179
00:09:11,770 --> 00:09:14,443
if they have doubled the points of the Koalas,
180
180
00:09:15,663 --> 00:09:16,713
that's the condition.
181
181
00:09:18,050 --> 00:09:20,200
So again, a team only wins
182
182
00:09:20,200 --> 00:09:22,840
if it has at least doubled the average score
183
183
00:09:22,840 --> 00:09:23,913
of the other team.
184
184
00:09:25,350 --> 00:09:27,650
And so that's why I told you here in this hint
185
185
00:09:28,916 --> 00:09:30,710
that this is how we check for that.
186
186
00:09:30,710 --> 00:09:34,560
So A has double the amount of points of B
187
187
00:09:34,560 --> 00:09:37,373
if A is greater than two times B.
188
188
00:09:38,930 --> 00:09:40,913
So let's do that.
189
189
00:09:42,730 --> 00:09:46,130
So average Dolphins greater
190
190
00:09:46,130 --> 00:09:50,467
or equal to two times the average Koalas.
191
191
00:09:52,640 --> 00:09:55,610
And in this case, we look to the console
192
192
00:09:59,480 --> 00:10:02,910
Dolphins win the trophy,
193
193
00:10:02,910 --> 00:10:04,600
let's use an emoji here again
194
194
00:10:05,510 --> 00:10:08,040
but you don't need of course to do that.
195
195
00:10:08,040 --> 00:10:09,223
So it's already here,
196
196
00:10:10,450 --> 00:10:14,023
and now it also told us to put the points.
197
197
00:10:16,750 --> 00:10:20,083
For example, 30 versus 13,
198
198
00:10:21,050 --> 00:10:24,220
so both points with the versus in between.
199
199
00:10:24,220 --> 00:10:27,390
So that's average Dolphins
200
200
00:10:32,170 --> 00:10:34,600
versus average Koalas.
201
201
00:10:34,600 --> 00:10:35,500
So you'll see that here
202
202
00:10:35,500 --> 00:10:38,730
we are also practicing all the other skills
203
203
00:10:38,730 --> 00:10:41,150
that we already acquired before.
204
204
00:10:41,150 --> 00:10:42,913
Especially in the previous section.
205
205
00:10:45,810 --> 00:10:48,810
Then now here we need to just need to do the opposite.
206
206
00:10:48,810 --> 00:10:50,193
So else if,
207
207
00:10:52,510 --> 00:10:57,110
and now if the Koalas half at least.
208
208
00:10:57,110 --> 00:11:00,160
So that's basically what this one here means.
209
209
00:11:00,160 --> 00:11:03,590
So greater equal is basically at least.
210
210
00:11:03,590 --> 00:11:04,823
So if average Koalas
211
211
00:11:04,823 --> 00:11:09,343
have at least double the points of the Dolphins,
212
212
00:11:11,110 --> 00:11:13,500
then the Koalas win.
213
213
00:11:13,500 --> 00:11:16,233
So that's just grab this one from here.
214
214
00:11:17,580 --> 00:11:22,440
Koalas and tier it's average Koalas,
215
215
00:11:22,440 --> 00:11:26,640
and then average Dolphins, average, yes.
216
216
00:11:30,620 --> 00:11:33,210
And now in any other case,
217
217
00:11:33,210 --> 00:11:35,800
we say that no one wins.
218
218
00:11:35,800 --> 00:11:38,063
So I think that's also said in the rules.
219
219
00:11:39,260 --> 00:11:41,150
Yeah, that's a number of five.
220
220
00:11:41,150 --> 00:11:44,280
I think I even forgot to tell you this one
221
221
00:11:44,280 --> 00:11:45,773
but hopefully you read it.
222
222
00:11:47,603 --> 00:11:52,010
So you should ignore draws in this exercise this time.
223
223
00:11:52,010 --> 00:11:53,620
So if none of these is true,
224
224
00:11:53,620 --> 00:11:55,563
we simply say that no team wins.
225
225
00:11:58,840 --> 00:12:01,933
No team wins.
226
226
00:12:04,560 --> 00:12:08,453
And now all we need to do is to call this function here.
227
227
00:12:09,380 --> 00:12:13,320
So checkWinner, and we will do that
228
228
00:12:13,320 --> 00:12:15,350
with score Dolphins
229
229
00:12:16,410 --> 00:12:19,833
and score Koalas.
230
230
00:12:22,500 --> 00:12:26,890
Let's recap, we calculated the score of the Dolphins up here
231
231
00:12:26,890 --> 00:12:28,890
and of the Koalas as well.
232
232
00:12:28,890 --> 00:12:33,521
And now we call the checkWiner function here
233
233
00:12:33,521 --> 00:12:35,410
and we use as arguments
234
234
00:12:35,410 --> 00:12:37,960
the scores that we calculated before
235
235
00:12:37,960 --> 00:12:41,470
and then score Dolphins will become average Dolphins
236
236
00:12:42,960 --> 00:12:44,130
here in this function,
237
237
00:12:44,130 --> 00:12:46,560
because that's the name of the parameter.
238
238
00:12:46,560 --> 00:12:48,740
And I see that I misspelled this,
239
239
00:12:48,740 --> 00:12:50,870
and so now I can use that command D
240
240
00:12:50,870 --> 00:12:53,400
that I talked to you about before,
241
241
00:12:53,400 --> 00:12:55,180
so I can select all of them.
242
242
00:12:55,180 --> 00:12:58,150
So command D, command D,command D, command D
243
243
00:12:58,150 --> 00:13:01,330
and now I can use all of these cursors here
244
244
00:13:01,330 --> 00:13:02,460
at the same time.
245
245
00:13:02,460 --> 00:13:06,340
So Dolphins you see,
246
246
00:13:06,340 --> 00:13:10,733
I inserted the P in all of the variable names everywhere.
247
247
00:13:14,140 --> 00:13:17,420
And so now this parameter name here gets used
248
248
00:13:17,420 --> 00:13:19,750
for all these calculations.
249
249
00:13:19,750 --> 00:13:23,970
And again, originally this value comes basically from here,
250
250
00:13:23,970 --> 00:13:27,850
from calculating the average of these three scores.
251
251
00:13:27,850 --> 00:13:30,040
So this average gets stored here
252
252
00:13:30,040 --> 00:13:31,990
then we use it here
253
253
00:13:31,990 --> 00:13:35,810
and then it gets basically transferred to average Dolphins
254
254
00:13:35,810 --> 00:13:38,213
and is then used everywhere in this function.
255
255
00:13:40,330 --> 00:13:41,860
So let's now test.
256
256
00:13:41,860 --> 00:13:44,400
And as we expected, no team wins
257
257
00:13:44,400 --> 00:13:46,400
because this team here
258
258
00:13:46,400 --> 00:13:50,330
even though it has more than the Dolphins, it's not double.
259
259
00:13:50,330 --> 00:13:52,293
And so therefore they do not win.
260
260
00:13:53,150 --> 00:13:56,450
Now of course, what is also important to mention here
261
261
00:13:56,450 --> 00:13:59,750
is that this checkWiner function here
262
262
00:13:59,750 --> 00:14:04,170
is also completely independent of these score values
263
263
00:14:04,170 --> 00:14:06,210
that we calculated earlier.
264
264
00:14:06,210 --> 00:14:09,230
So here we can simply call this function
265
265
00:14:09,230 --> 00:14:11,320
with completely different values.
266
266
00:14:11,320 --> 00:14:12,860
So the function doesn't care
267
267
00:14:12,860 --> 00:14:14,610
where do these values come from.
268
268
00:14:14,610 --> 00:14:18,360
So where average Dolphins and average Koalas come from.
269
269
00:14:18,360 --> 00:14:20,050
It's a standalone function
270
270
00:14:20,050 --> 00:14:23,200
and it doesn't care at all, where it is values came from.
271
271
00:14:23,200 --> 00:14:25,400
We can just plug in some random numbers here
272
272
00:14:26,950 --> 00:14:30,363
and then call it and let's use a smaller number here.
273
273
00:14:31,530 --> 00:14:34,120
So just to that, the average Dolphin here
274
274
00:14:34,120 --> 00:14:37,023
is actually more than double of the average Koalas.
275
275
00:14:38,776 --> 00:14:40,300
So if you run this now,
276
276
00:14:40,300 --> 00:14:45,300
then we see that the Dolphins win with 576 versus 111.
277
277
00:14:46,570 --> 00:14:48,330
And so that's exactly the numbers
278
278
00:14:48,330 --> 00:14:50,433
that we plugged in in here.
279
279
00:14:52,200 --> 00:14:55,000
So once more, it's important to keep in mind
280
280
00:14:55,000 --> 00:14:58,100
that these functions are all independent from another.
281
281
00:14:58,100 --> 00:15:00,820
We just happen to call checkWiner here
282
282
00:15:00,820 --> 00:15:03,320
with these values that we calculated before,
283
283
00:15:03,320 --> 00:15:05,400
but it's not mandatory to do that,
284
284
00:15:05,400 --> 00:15:08,600
any other values will work just as well.
285
285
00:15:08,600 --> 00:15:10,003
And so we proved that here.
286
286
00:15:11,020 --> 00:15:14,800
Anyway, now let's use test data two,
287
287
00:15:14,800 --> 00:15:16,060
and actually what I'm gonna do
288
288
00:15:16,060 --> 00:15:19,660
is to reassign these two scores here.
289
289
00:15:19,660 --> 00:15:21,260
So we calculate them first,
290
290
00:15:21,260 --> 00:15:23,660
then we call checkWinner
291
291
00:15:23,660 --> 00:15:26,050
and then I'm going to recalculate them
292
292
00:15:26,050 --> 00:15:27,723
and call checkWinner again.
293
293
00:15:28,816 --> 00:15:30,330
What I mean by saying that
294
294
00:15:30,330 --> 00:15:34,530
is that these need to be let variables
295
295
00:15:34,530 --> 00:15:37,093
so that we can reassign them, remember that?
296
296
00:15:38,270 --> 00:15:40,860
Const values cannot be mutated,
297
297
00:15:40,860 --> 00:15:42,153
they cannot be changed,
298
298
00:15:43,539 --> 00:15:45,530
and so they need to be let.
299
299
00:15:45,530 --> 00:15:49,350
And then here, of course, we need to get rid of the let,
300
300
00:15:49,350 --> 00:15:52,340
because we do not want to create new variables,
301
301
00:15:52,340 --> 00:15:54,050
we just want to overwrite.
302
302
00:15:54,050 --> 00:15:55,670
So we want to reassign
303
303
00:15:55,670 --> 00:15:57,683
the values that we had earlier.
304
304
00:15:59,290 --> 00:16:00,840
So this time the values
305
305
00:16:03,886 --> 00:16:05,643
are 85, 54 and 41.
306
306
00:16:12,276 --> 00:16:14,600
85, 54 and 41.
307
307
00:16:14,600 --> 00:16:16,680
And I hope that's correct.
308
308
00:16:16,680 --> 00:16:19,343
And then for the Koalas,
309
309
00:16:21,389 --> 00:16:24,233
we have 23, 34 and 27.
310
310
00:16:26,050 --> 00:16:30,843
So that's 23, 34 and 27.
311
311
00:16:33,450 --> 00:16:35,543
Let's lock these actually also,
312
312
00:16:39,082 --> 00:16:41,220
and then simply call checkWinner again,
313
313
00:16:41,220 --> 00:16:42,820
and now with the new values
314
314
00:16:42,820 --> 00:16:46,883
of score Dolphins and score Koalas that we just reassigned.
315
315
00:16:50,096 --> 00:16:51,803
So let's see.
316
316
00:16:52,870 --> 00:16:55,850
And now the Dolphins seven average score of 60
317
317
00:16:55,850 --> 00:16:57,610
and to Koalas of 28.
318
318
00:16:57,610 --> 00:16:59,960
And so now the Dolphins win
319
319
00:16:59,960 --> 00:17:03,150
with a 60 versus 28.
320
320
00:17:03,150 --> 00:17:05,240
So that's a close call.
321
321
00:17:05,240 --> 00:17:07,470
So if the Koalas had three more points
322
322
00:17:07,470 --> 00:17:09,030
then no one would win,
323
323
00:17:09,030 --> 00:17:11,433
but the Dolphins managed to do it.
324
324
00:17:12,740 --> 00:17:17,740
Great, I hope that this all made sense to you,
325
325
00:17:18,330 --> 00:17:20,530
and I know it is probably still
326
326
00:17:20,530 --> 00:17:23,200
a bit confusing at this point.
327
327
00:17:23,200 --> 00:17:25,320
And if you did some things differently
328
328
00:17:25,320 --> 00:17:28,510
well then once more data's completely okay.
329
329
00:17:28,510 --> 00:17:29,890
It just means you're developing
330
330
00:17:29,890 --> 00:17:33,100
your own coding style over time.
331
331
00:17:33,100 --> 00:17:35,940
For example, here with the average scores,
332
332
00:17:35,940 --> 00:17:39,230
of course you could have created new variables down here
333
333
00:17:39,230 --> 00:17:41,300
for the test data too.
334
334
00:17:41,300 --> 00:17:42,910
So that's just one of many things
335
335
00:17:42,910 --> 00:17:44,740
that you could have done differently
336
336
00:17:44,740 --> 00:17:46,190
which are perfectly fine.
337
337
00:17:46,190 --> 00:17:50,100
As long as your results are the same, you're good to go.
338
338
00:17:50,100 --> 00:17:53,210
So take some time and review this lecture.
339
339
00:17:53,210 --> 00:17:55,620
Remember that you can check out my final code
340
340
00:17:55,620 --> 00:18:00,350
also in the final folder and the GitHub repo,
341
341
00:18:00,350 --> 00:18:04,610
and then you're ready to move on to our next big topic
342
342
00:18:04,610 --> 00:18:05,780
in the section,
343
343
00:18:05,780 --> 00:18:07,630
which is gonna be arrays.
344
344
00:18:07,630 --> 00:18:09,623
So I hope to see you there soon.
29137
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.