All language subtitles for 024 Challenge 11 Solution_en

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 Download
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:00,390 --> 00:00:03,200 All right, let's go through the answer to this challenge. 2 00:00:03,360 --> 00:00:10,290 The steps that we need to perform are we need to create a global container inside our app.js to 3 00:00:10,290 --> 00:00:15,260 be able to store each of the posts that come in through this post route 4 00:00:15,450 --> 00:00:23,700 when we compose a new blog post. And then we need to be able to redirect from this post route to our get 5 00:00:23,700 --> 00:00:27,470 route for the home page or the root route. 6 00:00:27,780 --> 00:00:32,130 And there we're going to console log all of the posts that we've saved. 7 00:00:32,460 --> 00:00:39,010 So the first step is creating that global variable. You might have created something using a var 8 00:00:39,330 --> 00:00:46,740 and we said that we should call it posts which is plural to save all of our individual posts. And then 9 00:00:46,740 --> 00:00:49,850 we're going to set it to an empty array to begin with. 10 00:00:50,310 --> 00:00:57,190 So now inside our post route we're able to tap into that posts array, 11 00:00:57,390 --> 00:00:58,560 remember the s. 12 00:00:58,590 --> 00:01:06,540 And then we're going to use the push method to add elements into the array And you can easily find this 13 00:01:06,540 --> 00:01:06,790 out 14 00:01:06,840 --> 00:01:13,940 if you google for how to add new items to an array for example. There's a lot of methods and a lot of keywords 15 00:01:14,220 --> 00:01:16,210 but you don't have to remember any of them. 16 00:01:16,230 --> 00:01:19,520 Remember that programming is just like an open book exam. 17 00:01:19,590 --> 00:01:25,170 Everything is out there on the Internet for you to find and you don't have to resort to memorizing these 18 00:01:25,170 --> 00:01:26,490 things at all. 19 00:01:26,490 --> 00:01:29,580 You just have to know that they exist and roughly how they work. 20 00:01:29,820 --> 00:01:35,570 So now let's use this method push to add our you post item into it. 21 00:01:35,640 --> 00:01:40,610 At this stage we should at least have one item inside our new post array. 22 00:01:41,010 --> 00:01:49,890 Next it's time to use res.redirect in order to send our user back to the home page or the root 23 00:01:49,890 --> 00:01:50,680 route. 24 00:01:50,880 --> 00:01:58,340 And what this line will do is it will take us right over here and jump into this root route. 25 00:01:58,650 --> 00:02:05,910 It's at this stage where we'll console log our posts array so that we see all the posts that are currently 26 00:02:05,910 --> 00:02:07,220 stored inside. 27 00:02:07,560 --> 00:02:09,620 So now let's give it a spin. 28 00:02:09,930 --> 00:02:18,060 If we head over to our compose page and we add some mumbo jumbo in here, hit publish, we get redirect back 29 00:02:18,060 --> 00:02:26,250 to the home route and inside our console we get that new post printed and you can see that denoted by 30 00:02:26,340 --> 00:02:27,420 the square brackets, 31 00:02:27,420 --> 00:02:29,410 this is inside an array. 32 00:02:29,430 --> 00:02:36,120 The final thing that I would like to change is we know that this has to be a global variable, 33 00:02:36,180 --> 00:02:39,190 it has to be reached by all of these functions. 34 00:02:39,240 --> 00:02:45,750 So this is why it's right up at the top and it's outside of any of these other functions. 35 00:02:45,750 --> 00:02:49,580 The only thing I would change about this as we mentioned many times before, 36 00:02:49,830 --> 00:02:54,120 instead of using a var, you want to go from a let. 37 00:02:54,120 --> 00:02:56,790 So a let is a safer version of a var. 38 00:02:57,030 --> 00:02:59,330 So this is the solution to challenge 11. 3910

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