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
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

Now there is a

cleaner way to write this code on line 3, all this concatenations

are kind of ugly, they're getting in the way, later in the course I will show you

how to use template literals to clean up this code. For now,

don't worry about it, let's look at another example of a function.

This function we have here is performing a task. So,

Performing a task. This task is to display something on the

console. But sometimes our functions might calculate something,

so, here is an example of a function that calculates

a value. So again, function, let's call

this function square, this function should take a parameter, let's call

that number, now we need to calculate the square

of that number, that is number times number.

Just basic math. Right? Now we need to return this value

to whoever is calling this function. For that we use

the return keyword. That's another reserve keyword

so we cannot have a variable called return, okay? Now instead of

calling the greet function, let's call the square function. So,

square, we pass 2, now this returns a value

so we can use that value to initialize a variable.

For example, you can declare another

variable called number, and set it to a square of 2.

And then we can display that on the console.

Save the changes, so we get 4. Now,

in this particular example, we don't necessarily have to declare a separate

variable if all we want to do is display the square of 2

on the console. We can exclude this variable declaration,

and simply pass square of 2,

to console.log.

So, when the JavaScript engine executes

this code, first it's going to call this function, it will get a value

and then pass that value to console.log.

Save the changes and look we still get 4.

Now, I have a question for you. How many function calls do you think we

have in this code? We have 2 function calls.

Square of 2, is one function call, let me

delete this temporarily, but console.log is also

another function call, right? Because here we have parenthesis,

so, we're calling the log function, which is defined somewhere,

and passing an argument, we can pass a simple string,

like Hello, or we can pass an expression, that expression can be

a call to another function, like square of 2.

Okay? So this is the basics of functions. Again, later,

in the course we have a comprehensive section about functions, for now, all I want

you to take away, is that a function is a set of statements

that either performs a task, or calculates

and returns a value. A real world application is essentially

a collection of hundreds or thousands of functions working together

to provide the functionality of that application.

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