Okay, hopefully,
you managed to complete at least point 1 and point 2.
And so let's start by solving these two.
So number one is calculating the average of both teams.
So let's create one variable for each.
So scoreDolphins, and so to calculate the average,
we simply add up all the three scores
and then divide it by a three.
So we already did something similar before.
So that's 96 + 108 + 89,
and then divide it by 3.
And we need these parenthesis
so that these plus operations are executed first,
because the grouping, so the parenthesis,
have a higher precedence.
Okay, scoreKoalas is 88 + 91 + 110,
and again, divide it by 3.
And now let's quickly log both to the console here,
scoreDolphins and scoreKoalas.
Okay, so they're pretty close,
but the dolphins have a little bit higher of an average.
And so that's what we're working on in point 2,
where we're gonna compare the average of both teams.
So we are gonna use an 'if' statement
or 'if else' probably.
So scoreDolphins, if it's greater than scoreKoalas,
then log to the console 'Dolphins win the trophy.'
And we can get fancy here with some emoji.
Let's see if we got one up,
that's the one I'm looking for.
But of course, once more,
you don't need to worry about this part.
Let's just copy this for the next one.
So 'else,' and actually,
we're going to use an 'else if' because of the draw,
but let's talk about that one later.
So if the score of the koalas is greater than scoreDolphins,
then we're gonna print the opposite
so that koalas win the trophy.
And finally, 'else if,'
scoreDolphins is equal to scoreKoalas,
then we can simply say that no one wins the trophy,
or actually, both win the trophy.
Okay, so let's test that.
And indeed, we get that the dolphins win the trophy,
and that's because, as we know, this value is greater.
And so actually, this first condition here
turns out to be true right away.
And so this block of code here gets executed.
Now, let's just quickly increase
the score of the koalas here,
let's say 100, just to see if the second part also works.
And indeed, now the koalas win the trophy.
Okay, but let's put it back here.
And here you could have actually done it in another way.
So you could have done scoreDolphins less than scoreKoalas.
So, basically, write the same as here,
but instead of the greater, you would've used the less than.
So that's the exact same thing,
and both are equally valid.
Then here in the last part,
actually, we wouldn't even have needed this part,
so that the score of dolphins is equal to score of koalas,
because that's actually the only scenario that's left
given these previous two conditions.
So basically, if none of these here were true,
really the only thing possible
would be that they had the same score.
And so a simple 'else' block would've been enough here.
But anyway, this works just fine too.
And so, again, what matters is that you made it work
even if you did some things differently.
For example, you could have stored the conditions
in separate bullion variables,
or you could have structured the 'if else' statement
in some different way.
But if you got the same result that we just saw here,
then congratulations,
that's a great work, well done, really.
So maybe you even made it to Bonus number 1 and 2.
And so let me solve them here now as well.
So let's start by calculating the average.
So this is gonna be Bonus 1,
and yeah, let's copy this one too,
let's copy this one, let's copy this one,
so should have done it all in one go,
so that we can now comment out this first part.
So for test number 1, this should be 97.
Then the second one should be 112 and 101.
And for the koalas,
we have 109, 95, and 123.
Let's just quickly test.
And so right now, the koalas win the trophy.
So for now, everything works the same,
but now we need to include this important condition here,
which is that, with this rule,
a team only wins if it has a higher score
than the other team, which we already have,
and at the same time, a score of at least 100 points.
Okay, easy enough.
So in this case, the dolphins win, okay?
But now we also need to ensure
that the dolphins have a score higher or equal 100.
So let's just say that.
So dolphins need to have a higher score than koalas,
and scoreDolphins need to be greater or equal 100,
and that's it, that's all we need for this requirement.
And then the same thing here.
So this is the scenario where the koalas win.
So for the koalas to win,
they need to have a higher score than the dolphins,
and at the same time, they need to have at least 100 points,
so just like before, greater or equal 100.
And so once more, we used a logical operator here
to model this situation essentially, okay?
And actually, I think, with this,
we implemented this bonus number 1.
So let's try that again.
And right now, of course, it still works
because both have a score higher than 100.
But let's change that now here,
according to test data 2, to 106, so 106,
and now they both win the trophy.
So let's actually decrease all of these points by 20.
So let's make it 81 and 86.
So the average should still be the same now, yeah,
but they're both below 100 now.
And so this brings us to bonus number 2
that says that the minimum score
should also apply to a draw.
So a draw only happens when both teams have the same score
and both a score greater or equal 100 points, okay?
And otherwise, no team wins the trophy,
so that's important too.
So let's translate that.
So to be a draw, the score needs to be the same,
which we already have,
and the score of dolphins
needs to be greater or equal 100,
and the score of koalas
needs to be greater, equal 100, okay?
And else, well, then we can say that no one wins the trophy.
And let's just add some sad emoji here. (chuckling)
Okay, let's try that.
And now we get that no one wins the trophy, okay?
So that's because their scores are now below 100.
And so we actually enter this last case here.
But if we go back to the averages that we had before,
so 106 and 101, let's see,
and now both win the trophy
because they have the same amount of points
and they both have a number of points above 100.
And so that's exactly what we have here.
So same points, dolphins have over or at least 100 points
and koalas have at least 100 points.
And so in this case, both win the trophy.
Finally, let's also test the scenario
in which both have below,
but the dolphins have a little bit more.
Let's put this one here at 80.
And so, now we see that the dolphins have 96 points
and the koalas have 84, but still, no one wins the trophy.
And that's because the dolphins have more than the koalas.
So this part of the requirement is true,
but they do not have over 100.
So this part here is false, okay?
And so true, this first part here is true,
and the second part is false,
and true and false gives false.
And so then, all of these are skipped
because they're also, obviously, false.
And so we go straight to this last block,
and so no one wins the trophy,
which is exactly what we were expecting
as a result here, okay?
Now, if you didn't manage to do this here,
again, don't worry, because I know
that this is a little bit complicated already.
And so, in case you managed
to successfully complete this challenge,
then a huge congratulations to you, well done.
But if, for some reason,
you were not able to complete the challenge,
then don't worry all too much about it.
You can always go back to the lectures
where we first learned about these topics.
And you can, of course, after this video,
also review the code a little bit more carefully
to make sure 100% that you understand,
especially this last example that we just worked on, okay?
But anyway, great job in completing this challenge,
and now I see you in the next video.