All language subtitles for 14. Coding Challenge #2

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
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

1 1

Welcome to the second coding challenge. 2

2

In this one you're gonna test your knowledge 3

3

of the if/else statement that we just learned about. 4

4

This coding challenge number two 5

5

will basically improve the first challenge. 6

6

We're still gonna be using DBMI example, 7

7

but we are going to print a nice output to the console 8

8

and this output is gonna tell us who has the higher BMI. 9

9

The output message can be either 10

10

Mark's BMI is higher than John's 11

11

or John's BMI is higher than Mark's. 12

12

That's the first part, 13

13

and then as a second part use a template string 14

14

to include the actual BMI values in the outputs. 15

15

Okay, and as you can guess, 16

16

you should probably use an if/else statement 17

17

to complete this challenge, right? 18

18

So, pause the video now and I'll see you in a second. 19

19

All right. 20

20

Again, I hope that you managed to do this. 21

21

Let me show you how I did it. 22

22

Let's start by getting this code from the other challenge, 23

23

so coding challenge number one, 24

24

because of course we don't have to repeat the same code. 25

25

Here we have the mass and the height of both John and Mark, 26

26

and we already have their BMIs calculated. 27

27

We also have this condition here basically already, 28

28

so this operation here already tells us 29

29

whether Mark has a higher BMI or not, right? 30

30

Let's get rid of this 31

31

and let's write our if/else statement. 32

32

If BMIMark is greater than BMIJohn, 33

33

and here we could have just used this variable, 34

34

so we could have written Mark higher BMI right here, 35

35

but as I said in the previous lecture 36

36

it's actually more common 37

37

to write the condition directly in here. 38

38

Let's get rid of this variable here, 39

39

and then let's come here and get this string 40

40

that we want to then log to the console. 41

41

So console.log, 42

42

and so this makes sense, right? 43

43

If BMIMark is greater than BMIJohn, 44

44

then we log to the console Mark's BMI is higher than John's, 45

45

and if not, then we use the else statement. 46

46

Let's copy this one here. 47

47

In this case, John's BMI is higher than Mark's, 48

48

and actually let's log both of them 49

49

to the console here first, 50

50

just so we see if our if/else statement 51

51

is working as expected. 52

52

So BMIMark and BMIJohn. 53

53

As you see here, the VS code autocompletion is pretty smart. 54

54

Give it a safe, let's try that, 55

55

and we see John's BMI is higher than Mark's. 56

56

So this one is Mark's, this one is John's, 57

57

and indeed John's BMI is higher. 58

58

Basically this condition here turned out to be false 59

59

and the else block was executed. 60

60

Let's try the same now with this first set of data here, 61

61

and I'm commenting them out again using command slash 62

62

or control slash on Windows. 63

63

I need to comment out this one, 64

64

okay, give it a safe, 65

65

and now we should see the opposite. 66

66

Indeed, now Mark's BMI is higher than John's. 67

67

That is part one, 68

68

and now part two is to actually write a template string, 69

69

or this would be called a template literal. 70

70

We just fix that. 71

71

We should use a template literal 72

72

to include the actual BMI values, 73

73

so like this here between parenthesis. 74

74

So, let's do that. 75

75

We're going to transform this to backticks. 76

76

That's the first thing, 77

77

and then let's see the template again. 78

78

Okay, so after the BMI we include two parenthesis 79

79

and then in the parenthesis 80

80

is where we want the actual value. 81

81

This is where we put essentially the placeholder. 82

82

Here we will put BMIMark 83

83

and here BMIJohn. 84

84

Now let's just copy this to make it a bit faster. 85

85

Mark, and down here, John. 86

86

Okay, let's see. 87

87

Yeah, that works just fine. 88

88

Cool, so with this we solved the challenge, 89

89

and again, if you did it in a slightly different way, 90

90

don't worry at all. 91

91

That's completely normal and it's actually a good thing. 92

92

It means that you're basically finding 93

93

your own style of coding, which is a really a good thing 94

94

so don't worry about that. 95

95

What matters is that you actually used an if/else statement. 96

96

That was, of course, mandatory. 97

97

Otherwise you couldn't have made this work at all. 98

98

All right, so this was a lot of fun 99

99

because we actually made our code do something now. 100

100

I hope you can really feel that as well.

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