All right, I hope you managed
to complete all the three points of this challenge.
And so here is how I would have implemented it.
So I'm starting with number one, of course,
and so let's say, const massMark
equals 78.
Okay, so that's just what is written here.
And then heightMark
equals 1.69.
And then the same for John,
so massJohn equals 92,
and then heightJohn equals 1.95.
All right?
And if you used different variable names,
that's not a problem at all.
As long as they are nicely descriptive
like these ones here, you're gonna be fine.
Also, you might have used let here instead of const
because you might assume
that these are values that are susceptible to change,
especially here, the mass, right?
However, I still decided to use const
because I already know
that I'm not gonna change these values here
throughout the program.
And so just as we learned before,
I prefer to always use const by default,
and I advise you to actually do the same, okay?
Anyway, let's now calculate the actual BMIs.
So const BMIMark
equals massMark divided...
And let's check out the formula again,
divided by the height squared.
So that's gonna be heightMark squared.
And then the BMI John,
so that's massJohn,
and this time, let's actually use the other formula.
So this one here.
So we're gonna use
heightJohn times heightJohn again.
Okay, and now let's log both of them to the console here.
So BMIMark and BMI John.
And now we have an error here.
Oh, of course, I missed the .log.
Okay, try it again.
And here we go.
So we see that BMIMark is higher than John's BMI.
Okay, so I hope you got the same numbers here than I did.
And if not, I guess you should probably check your code,
unless I have some mistake here.
Let me check that actually.
But I think everything is good.
Okay, so if something is wrong,
then please just let me know, all right?
Now, if you implemented this in a different way,
for example, you might not have created these
separate variables here.
then that's not a problem at all, okay?
You could have logged these calculations
straight to the console, no problem at all.
Again, what matters here is that you make this work
and that in the end, you get these same results here.
Anyway, let's now also do step three
and create a variable called markHigherBMI.
So let's just grab this here,
and const.
And so what we're trying to figure out
is if the BMI of Mark
is higher than the BMI of John, right?
And so that's what comparison operators are for
because remember, that this one here
will return either true or false.
In our example, if BMIMark is larger than one of John,
then the result of this whole operator here will be true
and otherwise, it's gonna be false, okay?
So that's exactly what we did before in this example
with the ages, if I remember correctly.
So where's that?
Ah, yeah, it's right here.
In this case it was the isFullAge variable, right?
Okay.
Anyway, let's log it here to the console as well.
And so we expect this one to be true, right?
Because Mark's BMI is 27 and John's is 24.
And so Mark's is larger,
and so the result of this should be true.
So let's check that.
And indeed, we get true.
Nice. So we basically solved it.
Now I just want to do the same here for test data too.
So I'll just copy this.
So copy and then I will simply comment out these first ones.
So now I'm replacing these with 95, 1.88.
And then here for John, we have 85 and 1.76.
And the rest of course is the same.
And that's the beauty of using variables
because now all we have to do
is to change these values in one place
and then the changes will be propagated
to the rest of the code here.
which references these variables.
Cool. So let's reload.
And now BMI of John is 27,
so it's larger than 26.8.
It's actually very close
but still, BMIMark is now lower than BMIJohn.
So here we, ask the question basically,
is BMIMark larger than BMIJohn?
And in this case, it's not,
so it's false.
And so that's exactly the result that we get here.
All right.
So this one is solved and I hope you solved it as well.
Again, it does not matter at all
if you did it in a different way,
as long as the results were the same.
So basically, as long as you actually made it work.
So hopefully that was a lot of fun
and you could practice your skills a little bit,
which is really something essential
to learn programming properly.
Without repetition and reinforcing your knowledge,
it's impossible really to learn how to coach.
Anyway, see you now in the next video
where we're gonna continue learning the fundamentals
of the beautiful JavaScript language.