All language subtitles for 011 Coding Challenge

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

It's now finally time

for your very first coding challenge.

So coding challenges are basically coding exercises

that you have to code on your own,

and they are super important for you to test

and reinforce all the skills

that you just learned before.

That's why there are dozens of coding challenges

in this course, because students love them and they are one

of the best ways of learning.

And so this is the coding challenge number one

of the section or coding exercise

if you prefer to call it that.

Now all of these coding challenges are also

in a separate PDF file

that is available somewhere

in the course.

So you can also get this text from there.

You don't have to read the video.

Okay. Now, anyway, the exercise is this

Mark and John are trying

to compare their body mass indexes and the BMI

is calculated using this formula.

So BMI is equal to mass divided by the height squared.

Okay.

And so squared is the exponentiation operator that we talked

about before with the two.

Okay.

And so that is also the same

to mass equals height times height.

Okay.

So this part is the same as this one.

So you can choose

to calculate the BMI either way.

Now, what matters is that a mass needs to be

in kilograms and to height needs to be in meters.

So it's not gonna work

with the U.S measures like feet and pound,

but that's why I have the test data here already

with the correct measurements.

Anyway, here is what I want you to do for this challenge.

One, you should store mark's and John's mass

and height in variables,

and you should do this for test data one.

So this data here

and then also for test data two, all right,

then using these variables calculate both

their BMI's using the formula that I just showed you.

And again, you can use either one,

it's gonna work the same way.

Of course, to then check these values if they make sense,

you can log them to the console,

just like we have been doing up until this point.

Then finally, I want you

to create a Boolean variable called 'markHigherBMI',

which will contain the information,

whether Mark has a higher BMI than John.

Okay.

And this is actually similar to something

that we did before So I hope that

you can make this one work just fine.

So now please really try to solve this problem on your own.

And remember the advice that I gave you

in the beginning.

Don't try to make this perfect for now.

What matters is really just to make it work.

It doesn't matter if you write clean code

or perfect code or efficient code,

just make it work for now.

All right.

So pause the video now And I see you

in a second with the solution.

All right.

I hope you manage 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 one 69

and then the same for John.

So massJohn equals 92

and then heightJohn equals one 95 now, 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 going to be fine.

Also, you might've used a let here instead of const,

because you might assume that these are values that

are susceptible to change,

especially here the mass, all right.

However, I still decided to use const because I already know

that I'm not going to 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 going to be heightMark squared

and then the BMIJohn 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 BMIJohn.

And now we have an error here.

Oh, of course I missed the dot 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 BMI Mark 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? It's right here.

In this case, it was 'isFullAge' variable.

Right?

Okay.

Anyway, let's log to your tutor 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 we'll just copy this.

So copy, and then I will simply comment

out these first ones.

So now I'm replacing these with 95,

one 88 and then here for John,

we have 85 and one 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 a larger than 26.8.

It's actually very close, but still,

BMIMark is now lower

than BMIJohn.

So here we asked the question basically

is BMIMark a 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 skillset 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 code.

Anyway, see you now in the next video

where we're going to continue learning the fundamentals

of the beautiful JavaScript language.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.