Again, I hope that you managed to do this.
So let me show you how I did it.
So let's start by getting this code
from the other challenge.
So coding challenge number 1,
because, of course, we don't have to repeat the same code.
So here we have the mass and the height
of both John and Mark,
and we already have their BMIs calculated.
We also have this condition here, basically, already.
So this operation here already tells us
whether Mark has a higher BMI or not, right?
So let's get rid of this,
and so let's write our if/else statement.
So if BMIMark is greater than BMIJohn,
and here we could have just used this variable, right?
So we could have written markHigherBMI right here,
but as I said in the previous lecture,
it's actually more common
to write the condition directly in here.
So let's get rid of this variable here,
and then let's come here and get this string
that we want to then log to the console.
So console.log.
And so this makes sense, right?
So if BMIMark is greater than BMIJohn,
then we log to the console,
"Mark's BMI is higher than John's!"
and if not, then we use the else statement.
So let's copy this one here.
So in this case, "John's BMI is higher than Mark's!"
And actually, let's log both of them
to the console here first,
just so we see if our if/else statement
is working as expected.
So BMIMark and BMIJohn.
And as you see here,
the VSCode autocompletion is pretty smart.
Give it a save. Let's try it out.
And we see "John's BMI is higher than Mark's!"
So this one is Mark's, this one is John's,
and indeed, John's BMI is higher.
And so basically, this condition here
turned out to be false,
and the else block was executed.
So let's try the same now with this first set of data here.
And I'm commenting them out, again, using command slash,
or control slash on Windows.
So I need to comment out this one.
Okay, give it a save, and now we should see the opposite.
And indeed, now Mark's BMI is higher than John's.
So that is part 1, right?
And now part 2 is to actually write a template string,
or this would be called a template literal.
We just fix that.
So we should use a template literal
to include the actual BMI values,
so like this here, between parentheses.
So let's do that,
and so we're gonna transform this to backticks.
So that's the first thing,
and then let's see the template again.
Okay, so after the BMI, we included parentheses,
and then in the parentheses
is where we want the actual value.
And so this is where we put essentially the placeholder.
So here, we will put BMIMark,
and here, BMIJohn, right?
And now let's just copy this to make it a bit faster.
Mark, and then here, John.
Okay.
Let's see.
And yeah, that works just fine.
Cool. So with this, we solved the challenge.
And again, if you did it in a slightly different way,
don't worry at all.
That's completely normal, and it's actually a good thing.
It means that you're basically finding
your own style of coding, which is really a good thing,
so don't worry about that.
What matters is that you actually used an if/else statement.
That was, of course, mandatory.
Otherwise, you couldn't have made this work at all.
All right?
So this was a lot of fun,
because we actually made our code do something now.
I hope you can really feel that as well.