All language subtitles for 4- While

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

In the last lecture,

we wrote this for loop to display all the odd numbers

between 0 and 5. And in this lecture, I'm going to show you how to

implement the same logic by using a while loop. Now one

key difference between a y loop and a for loop is that in for loops

the loop variable is part of the loop variable itself.

But in y loops, you have to declare this y variable externally. Let me show

you what I mean. So we start with declaring

a variable like i and set it to 0. Note that this

i we have here is different from the i we have in this for loop,

because this variable is only meaningful and accessible

inside of this for loop. This is called scope, and I'm going to talk about

it later in the course, all I want you to know is that these two

variables are completely different, even though their names are the same.

Now, we have our loop variable initialized to 0.

Next we add a while statement,

in parenthesis we need to add our condition. What is the condition

here? That is i less than or equal

to 5. So I'm going to add that here. Next,

we need to add our statements. So what is the statement that

we want to repeat, here's the statement, we want to display

the odd numbers, so we add that here as well,

and finally, at the end of this while block we need

to increment i. So this is a direct translation

of this for loop into a y loop.

So this is what happens when we execute this code. Initially I

is 0, now in the y loop, first this condition

is evaluated, if this condition is true, then the

body of the y loop will be executed. Again, in the next iteration

the condition is evaluated again, if it's true, the

statements in the y block will be executed, otherwise the while block

will terminate. In the next lecture we're going to look at another kind of

loops in JavaScript.

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