All language subtitles for 8- Types of Functions

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 Download
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: WEBVTT 1 00:00:00.000 --> 00:00:04.000 Now there is a 2 00:00:04.000 --> 00:00:08.000 cleaner way to write this code on line 3, all this concatenations 3 00:00:08.000 --> 00:00:12.000 are kind of ugly, they're getting in the way, later in the course I will show you 4 00:00:12.000 --> 00:00:16.000 how to use template literals to clean up this code. For now, 5 00:00:16.000 --> 00:00:20.000 don't worry about it, let's look at another example of a function. 6 00:00:20.000 --> 00:00:24.000 This function we have here is performing a task. So, 7 00:00:24.000 --> 00:00:28.000 Performing a task. This task is to display something on the 8 00:00:28.000 --> 00:00:32.000 console. But sometimes our functions might calculate something, 9 00:00:32.000 --> 00:00:36.000 so, here is an example of a function that calculates 10 00:00:36.000 --> 00:00:40.000 a value. So again, function, let's call 11 00:00:40.000 --> 00:00:44.000 this function square, this function should take a parameter, let's call 12 00:00:44.000 --> 00:00:48.000 that number, now we need to calculate the square 13 00:00:48.000 --> 00:00:52.000 of that number, that is number times number. 14 00:00:52.000 --> 00:00:56.000 Just basic math. Right? Now we need to return this value 15 00:00:56.000 --> 00:01:00.000 to whoever is calling this function. For that we use 16 00:01:00.000 --> 00:01:04.000 the return keyword. That's another reserve keyword 17 00:01:04.000 --> 00:01:08.000 so we cannot have a variable called return, okay? Now instead of 18 00:01:08.000 --> 00:01:12.000 calling the greet function, let's call the square function. So, 19 00:01:12.000 --> 00:01:16.000 square, we pass 2, now this returns a value 20 00:01:16.000 --> 00:01:20.000 so we can use that value to initialize a variable. 21 00:01:20.000 --> 00:01:24.000 For example, you can declare another 22 00:01:24.000 --> 00:01:28.000 variable called number, and set it to a square of 2. 23 00:01:28.000 --> 00:01:32.000 And then we can display that on the console. 24 00:01:32.000 --> 00:01:36.000 Save the changes, so we get 4. Now, 25 00:01:36.000 --> 00:01:40.000 in this particular example, we don't necessarily have to declare a separate 26 00:01:40.000 --> 00:01:44.000 variable if all we want to do is display the square of 2 27 00:01:44.000 --> 00:01:48.000 on the console. We can exclude this variable declaration, 28 00:01:48.000 --> 00:01:52.000 and simply pass square of 2, 29 00:01:52.000 --> 00:01:56.000 to console.log. 30 00:01:56.000 --> 00:02:00.000 So, when the JavaScript engine executes 31 00:02:00.000 --> 00:02:04.000 this code, first it's going to call this function, it will get a value 32 00:02:04.000 --> 00:02:08.000 and then pass that value to console.log. 33 00:02:08.000 --> 00:02:12.000 Save the changes and look we still get 4. 34 00:02:12.000 --> 00:02:16.000 Now, I have a question for you. How many function calls do you think we 35 00:02:16.000 --> 00:02:20.000 have in this code? We have 2 function calls. 36 00:02:20.000 --> 00:02:24.000 Square of 2, is one function call, let me 37 00:02:24.000 --> 00:02:28.000 delete this temporarily, but console.log is also 38 00:02:28.000 --> 00:02:32.000 another function call, right? Because here we have parenthesis, 39 00:02:32.000 --> 00:02:36.000 so, we're calling the log function, which is defined somewhere, 40 00:02:36.000 --> 00:02:40.000 and passing an argument, we can pass a simple string, 41 00:02:40.000 --> 00:02:44.000 like Hello, or we can pass an expression, that expression can be 42 00:02:44.000 --> 00:02:48.000 a call to another function, like square of 2. 43 00:02:48.000 --> 00:02:52.000 Okay? So this is the basics of functions. Again, later, 44 00:02:52.000 --> 00:02:56.000 in the course we have a comprehensive section about functions, for now, all I want 45 00:02:56.000 --> 00:03:00.000 you to take away, is that a function is a set of statements 46 00:03:00.000 --> 00:03:04.000 that either performs a task, or calculates 47 00:03:04.000 --> 00:03:08.000 and returns a value. A real world application is essentially 48 00:03:08.000 --> 00:03:12.000 a collection of hundreds or thousands of functions working together 49 00:03:12.000 --> 00:03:16.000 to provide the functionality of that application. 4299

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