All language subtitles for 019 Coding Challenge #2.en_US

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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,210 --> 00:00:04,710 Welcome to the second coding challenge. 2 00:00:04,710 --> 00:00:07,130 In this one you're gonna test your knowledge 3 00:00:07,130 --> 00:00:10,553 of the if/else statement that we just learned about. 4 00:00:12,220 --> 00:00:14,110 This coding challenge number two 5 00:00:14,110 --> 00:00:17,510 will basically improve the first challenge. 6 00:00:17,510 --> 00:00:20,420 We're still gonna be using DBMI example, 7 00:00:20,420 --> 00:00:24,430 but we are going to print a nice output to the console 8 00:00:24,430 --> 00:00:27,513 and this output is gonna tell us who has the higher BMI. 9 00:00:29,000 --> 00:00:30,810 The output message can be either 10 00:00:30,810 --> 00:00:33,770 Mark's BMI is higher than John's 11 00:00:33,770 --> 00:00:37,250 or John's BMI is higher than Mark's. 12 00:00:37,250 --> 00:00:38,420 That's the first part, 13 00:00:38,420 --> 00:00:41,700 and then as a second part use a template string 14 00:00:41,700 --> 00:00:45,653 to include the actual BMI values in the outputs. 15 00:00:47,040 --> 00:00:49,010 Okay, and as you can guess, 16 00:00:49,010 --> 00:00:51,940 you should probably use an if/else statement 17 00:00:51,940 --> 00:00:55,140 to complete this challenge, right? 18 00:00:55,140 --> 00:00:57,963 So, pause the video now and I'll see you in a second. 19 00:01:00,820 --> 00:01:02,000 All right. 20 00:01:02,000 --> 00:01:04,993 Again, I hope that you managed to do this. 21 00:01:07,610 --> 00:01:10,600 Let me show you how I did it. 22 00:01:10,600 --> 00:01:14,590 Let's start by getting this code from the other challenge, 23 00:01:14,590 --> 00:01:16,810 so coding challenge number one, 24 00:01:16,810 --> 00:01:21,513 because of course we don't have to repeat the same code. 25 00:01:24,930 --> 00:01:29,930 Here we have the mass and the height of both John and Mark, 26 00:01:30,307 --> 00:01:33,760 and we already have their BMIs calculated. 27 00:01:33,760 --> 00:01:38,760 We also have this condition here basically already, 28 00:01:38,820 --> 00:01:40,970 so this operation here already tells us 29 00:01:40,970 --> 00:01:44,503 whether Mark has a higher BMI or not, right? 30 00:01:45,403 --> 00:01:47,890 Let's get rid of this 31 00:01:48,990 --> 00:01:51,523 and let's write our if/else statement. 32 00:01:53,097 --> 00:01:56,014 If BMIMark is greater than BMIJohn, 33 00:02:00,208 --> 00:02:04,005 and here we could have just used this variable, 34 00:02:04,005 --> 00:02:09,005 so we could have written Mark higher BMI right here, 35 00:02:09,330 --> 00:02:11,280 but as I said in the previous lecture 36 00:02:11,280 --> 00:02:12,620 it's actually more common 37 00:02:12,620 --> 00:02:14,963 to write the condition directly in here. 38 00:02:15,890 --> 00:02:18,972 Let's get rid of this variable here, 39 00:02:18,972 --> 00:02:22,740 and then let's come here and get this string 40 00:02:24,595 --> 00:02:28,900 that we want to then log to the console. 41 00:02:28,900 --> 00:02:30,333 So console.log, 42 00:02:32,010 --> 00:02:34,970 and so this makes sense, right? 43 00:02:34,970 --> 00:02:38,020 If BMIMark is greater than BMIJohn, 44 00:02:38,020 --> 00:02:41,993 then we log to the console Mark's BMI is higher than John's, 45 00:02:43,430 --> 00:02:47,100 and if not, then we use the else statement. 46 00:02:47,100 --> 00:02:48,350 Let's copy this one here. 47 00:02:54,203 --> 00:02:58,120 In this case, John's BMI is higher than Mark's, 48 00:02:59,410 --> 00:03:01,020 and actually let's log both of them 49 00:03:01,020 --> 00:03:04,033 to the console here first, 50 00:03:05,105 --> 00:03:09,363 just so we see if our if/else statement 51 00:03:09,363 --> 00:03:10,970 is working as expected. 52 00:03:10,970 --> 00:03:12,543 So BMIMark and BMIJohn. 53 00:03:15,690 --> 00:03:19,203 As you see here, the VS code autocompletion is pretty smart. 54 00:03:21,050 --> 00:03:23,633 Give it a safe, let's try that, 55 00:03:25,670 --> 00:03:29,740 and we see John's BMI is higher than Mark's. 56 00:03:29,740 --> 00:03:32,020 So this one is Mark's, this one is John's, 57 00:03:32,020 --> 00:03:35,470 and indeed John's BMI is higher. 58 00:03:35,470 --> 00:03:40,470 Basically this condition here turned out to be false 59 00:03:40,492 --> 00:03:43,243 and the else block was executed. 60 00:03:44,330 --> 00:03:49,330 Let's try the same now with this first set of data here, 61 00:03:49,440 --> 00:03:52,920 and I'm commenting them out again using command slash 62 00:03:52,920 --> 00:03:55,283 or control slash on Windows. 63 00:03:56,290 --> 00:03:58,053 I need to comment out this one, 64 00:03:59,640 --> 00:04:01,760 okay, give it a safe, 65 00:04:01,760 --> 00:04:04,060 and now we should see the opposite. 66 00:04:04,060 --> 00:04:07,573 Indeed, now Mark's BMI is higher than John's. 67 00:04:09,332 --> 00:04:11,183 That is part one, 68 00:04:13,195 --> 00:04:18,195 and now part two is to actually write a template string, 69 00:04:19,240 --> 00:04:21,923 or this would be called a template literal. 70 00:04:22,880 --> 00:04:23,993 We just fix that. 71 00:04:25,130 --> 00:04:26,950 We should use a template literal 72 00:04:26,950 --> 00:04:29,690 to include the actual BMI values, 73 00:04:29,690 --> 00:04:32,023 so like this here between parenthesis. 74 00:04:33,200 --> 00:04:34,483 So, let's do that. 75 00:04:35,863 --> 00:04:38,887 We're going to transform this to backticks. 76 00:04:44,040 --> 00:04:46,020 That's the first thing, 77 00:04:46,020 --> 00:04:50,280 and then let's see the template again. 78 00:04:50,280 --> 00:04:54,140 Okay, so after the BMI we include two parenthesis 79 00:04:54,140 --> 00:04:55,830 and then in the parenthesis 80 00:04:55,830 --> 00:04:57,573 is where we want the actual value. 81 00:04:58,409 --> 00:05:01,930 This is where we put essentially the placeholder. 82 00:05:01,930 --> 00:05:04,000 Here we will put BMIMark 83 00:05:12,393 --> 00:05:13,810 and here BMIJohn. 84 00:05:18,220 --> 00:05:21,163 Now let's just copy this to make it a bit faster. 85 00:05:24,390 --> 00:05:26,663 Mark, and down here, John. 86 00:05:33,220 --> 00:05:36,017 Okay, let's see. 87 00:05:37,758 --> 00:05:40,893 Yeah, that works just fine. 88 00:05:42,010 --> 00:05:45,060 Cool, so with this we solved the challenge, 89 00:05:45,060 --> 00:05:47,770 and again, if you did it in a slightly different way, 90 00:05:47,770 --> 00:05:49,000 don't worry at all. 91 00:05:49,000 --> 00:05:52,080 That's completely normal and it's actually a good thing. 92 00:05:52,080 --> 00:05:54,120 It means that you're basically finding 93 00:05:54,120 --> 00:05:58,500 your own style of coding, which is a really a good thing 94 00:05:58,500 --> 00:06:00,480 so don't worry about that. 95 00:06:00,480 --> 00:06:04,410 What matters is that you actually used an if/else statement. 96 00:06:04,410 --> 00:06:06,400 That was, of course, mandatory. 97 00:06:06,400 --> 00:06:10,170 Otherwise you couldn't have made this work at all. 98 00:06:10,170 --> 00:06:12,667 All right, so this was a lot of fun 99 00:06:12,667 --> 00:06:16,980 because we actually made our code do something now. 100 00:06:16,980 --> 00:06:19,523 I hope you can really feel that as well. 7301

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