1
00:00:01,050 --> 00:00:02,850
All right, I hope you managed

2
00:00:02,850 --> 00:00:06,990
to complete all the three points of this challenge.

3
00:00:06,990 --> 00:00:09,903
And so here is how I would have implemented it.

4
00:00:11,340 --> 00:00:14,970
So I'm starting with number one, of course,

5
00:00:14,970 --> 00:00:19,970
and so let's say, const massMark

6
00:00:21,450 --> 00:00:22,893
equals 78.

7
00:00:24,540 --> 00:00:26,973
Okay, so that's just what is written here.

8
00:00:28,448 --> 00:00:30,057
And then heightMark

9
00:00:33,720 --> 00:00:35,613
equals 1.69.

10
00:00:38,340 --> 00:00:40,770
And then the same for John,

11
00:00:40,770 --> 00:00:44,943
so massJohn equals 92,

12
00:00:46,350 --> 00:00:51,350
and then heightJohn equals 1.95.

13
00:00:53,370 --> 00:00:54,330
All right?

14
00:00:54,330 --> 00:00:56,610
And if you used different variable names,

15
00:00:56,610 --> 00:00:58,530
that's not a problem at all.

16
00:00:58,530 --> 00:01:00,720
As long as they are nicely descriptive

17
00:01:00,720 --> 00:01:03,480
like these ones here, you're gonna be fine.

18
00:01:03,480 --> 00:01:07,350
Also, you might have used let here instead of const

19
00:01:07,350 --> 00:01:08,460
because you might assume

20
00:01:08,460 --> 00:01:12,060
that these are values that are susceptible to change,

21
00:01:12,060 --> 00:01:14,760
especially here, the mass, right?

22
00:01:14,760 --> 00:01:17,310
However, I still decided to use const

23
00:01:17,310 --> 00:01:18,870
because I already know

24
00:01:18,870 --> 00:01:21,330
that I'm not gonna change these values here

25
00:01:21,330 --> 00:01:23,100
throughout the program.

26
00:01:23,100 --> 00:01:25,050
And so just as we learned before,

27
00:01:25,050 --> 00:01:28,320
I prefer to always use const by default,

28
00:01:28,320 --> 00:01:33,180
and I advise you to actually do the same, okay?

29
00:01:33,180 --> 00:01:37,320
Anyway, let's now calculate the actual BMIs.

30
00:01:37,320 --> 00:01:39,700
So const BMIMark

31
00:01:42,030 --> 00:01:46,677
equals massMark divided...

32
00:01:48,870 --> 00:01:51,180
And let's check out the formula again,

33
00:01:51,180 --> 00:01:54,030
divided by the height squared.

34
00:01:54,030 --> 00:01:58,780
So that's gonna be heightMark squared.

35
00:02:02,310 --> 00:02:06,003
And then the BMI John,

36
00:02:07,530 --> 00:02:09,960
so that's massJohn,

37
00:02:09,960 --> 00:02:13,380
and this time, let's actually use the other formula.

38
00:02:13,380 --> 00:02:15,063
So this one here.

39
00:02:16,380 --> 00:02:17,470
So we're gonna use

40
00:02:19,590 --> 00:02:24,590
heightJohn times heightJohn again.

41
00:02:25,140 --> 00:02:30,003
Okay, and now let's log both of them to the console here.

42
00:02:30,900 --> 00:02:35,850
So BMIMark and BMI John.

43
00:02:40,230 --> 00:02:42,540
And now we have an error here.

44
00:02:42,540 --> 00:02:45,183
Oh, of course, I missed the .log.

45
00:02:46,650 --> 00:02:49,290
Okay, try it again.

46
00:02:49,290 --> 00:02:51,420
And here we go.

47
00:02:51,420 --> 00:02:56,420
So we see that BMIMark is higher than John's BMI.

48
00:02:56,670 --> 00:03:01,260
Okay, so I hope you got the same numbers here than I did.

49
00:03:01,260 --> 00:03:05,040
And if not, I guess you should probably check your code,

50
00:03:05,040 --> 00:03:07,320
unless I have some mistake here.

51
00:03:07,320 --> 00:03:08,823
Let me check that actually.

52
00:03:09,900 --> 00:03:11,823
But I think everything is good.

53
00:03:12,660 --> 00:03:14,490
Okay, so if something is wrong,

54
00:03:14,490 --> 00:03:17,550
then please just let me know, all right?

55
00:03:17,550 --> 00:03:20,250
Now, if you implemented this in a different way,

56
00:03:20,250 --> 00:03:24,150
for example, you might not have created these

57
00:03:24,150 --> 00:03:25,920
separate variables here.

58
00:03:25,920 --> 00:03:28,800
then that's not a problem at all, okay?

59
00:03:28,800 --> 00:03:30,660
You could have logged these calculations

60
00:03:30,660 --> 00:03:33,870
straight to the console, no problem at all.

61
00:03:33,870 --> 00:03:36,870
Again, what matters here is that you make this work

62
00:03:36,870 --> 00:03:40,143
and that in the end, you get these same results here.

63
00:03:41,940 --> 00:03:45,810
Anyway, let's now also do step three

64
00:03:45,810 --> 00:03:49,620
and create a variable called markHigherBMI.

65
00:03:49,620 --> 00:03:51,243
So let's just grab this here,

66
00:03:53,790 --> 00:03:54,963
and const.

67
00:03:56,280 --> 00:03:58,110
And so what we're trying to figure out

68
00:03:58,110 --> 00:04:02,370
is if the BMI of Mark

69
00:04:02,370 --> 00:04:07,370
is higher than the BMI of John, right?

70
00:04:08,520 --> 00:04:11,790
And so that's what comparison operators are for

71
00:04:11,790 --> 00:04:14,730
because remember, that this one here

72
00:04:14,730 --> 00:04:17,880
will return either true or false.

73
00:04:17,880 --> 00:04:22,880
In our example, if BMIMark is larger than one of John,

74
00:04:23,640 --> 00:04:28,470
then the result of this whole operator here will be true

75
00:04:28,470 --> 00:04:31,440
and otherwise, it's gonna be false, okay?

76
00:04:31,440 --> 00:04:34,240
So that's exactly what we did before in this example

77
00:04:36,064 --> 00:04:39,480
with the ages, if I remember correctly.

78
00:04:39,480 --> 00:04:41,403
So where's that?

79
00:04:42,450 --> 00:04:44,310
Ah, yeah, it's right here.

80
00:04:44,310 --> 00:04:48,003
In this case it was the isFullAge variable, right?

81
00:04:49,590 --> 00:04:50,790
Okay.

82
00:04:50,790 --> 00:04:54,093
Anyway, let's log it here to the console as well.

83
00:04:55,440 --> 00:04:59,550
And so we expect this one to be true, right?

84
00:04:59,550 --> 00:05:04,410
Because Mark's BMI is 27 and John's is 24.

85
00:05:04,410 --> 00:05:07,110
And so Mark's is larger,

86
00:05:07,110 --> 00:05:09,960
and so the result of this should be true.

87
00:05:09,960 --> 00:05:11,163
So let's check that.

88
00:05:12,210 --> 00:05:14,313
And indeed, we get true.

89
00:05:15,180 --> 00:05:19,020
Nice. So we basically solved it.

90
00:05:19,020 --> 00:05:22,410
Now I just want to do the same here for test data too.

91
00:05:22,410 --> 00:05:23,733
So I'll just copy this.

92
00:05:24,690 --> 00:05:29,690
So copy and then I will simply comment out these first ones.

93
00:05:32,400 --> 00:05:36,683
So now I'm replacing these with 95, 1.88.

94
00:05:39,630 --> 00:05:44,383
And then here for John, we have 85 and 1.76.

95
00:05:46,290 --> 00:05:48,720
And the rest of course is the same.

96
00:05:48,720 --> 00:05:51,150
And that's the beauty of using variables

97
00:05:51,150 --> 00:05:52,710
because now all we have to do

98
00:05:52,710 --> 00:05:55,590
is to change these values in one place

99
00:05:55,590 --> 00:05:57,870
and then the changes will be propagated

100
00:05:57,870 --> 00:06:00,510
to the rest of the code here.

101
00:06:00,510 --> 00:06:03,213
which references these variables.

102
00:06:05,130 --> 00:06:07,560
Cool. So let's reload.

103
00:06:07,560 --> 00:06:12,560
And now BMI of John is 27,

104
00:06:13,290 --> 00:06:17,310
so it's larger than 26.8.

105
00:06:17,310 --> 00:06:19,200
It's actually very close

106
00:06:19,200 --> 00:06:24,200
but still, BMIMark is now lower than BMIJohn.

107
00:06:24,690 --> 00:06:27,360
So here we, ask the question basically,

108
00:06:27,360 --> 00:06:31,020
is BMIMark larger than BMIJohn?

109
00:06:31,020 --> 00:06:32,730
And in this case, it's not,

110
00:06:32,730 --> 00:06:33,990
so it's false.

111
00:06:33,990 --> 00:06:37,470
And so that's exactly the result that we get here.

112
00:06:37,470 --> 00:06:38,400
All right.

113
00:06:38,400 --> 00:06:43,020
So this one is solved and I hope you solved it as well.

114
00:06:43,020 --> 00:06:45,120
Again, it does not matter at all

115
00:06:45,120 --> 00:06:47,250
if you did it in a different way,

116
00:06:47,250 --> 00:06:49,650
as long as the results were the same.

117
00:06:49,650 --> 00:06:54,120
So basically, as long as you actually made it work.

118
00:06:54,120 --> 00:06:57,150
So hopefully that was a lot of fun

119
00:06:57,150 --> 00:06:59,850
and you could practice your skills a little bit,

120
00:06:59,850 --> 00:07:01,980
which is really something essential

121
00:07:01,980 --> 00:07:04,500
to learn programming properly.

122
00:07:04,500 --> 00:07:07,530
Without repetition and reinforcing your knowledge,

123
00:07:07,530 --> 00:07:11,130
it's impossible really to learn how to coach.

124
00:07:11,130 --> 00:07:13,500
Anyway, see you now in the next video

125
00:07:13,500 --> 00:07:15,990
where we're gonna continue learning the fundamentals

126
00:07:15,990 --> 00:07:18,423
of the beautiful JavaScript language.

