All language subtitles for 038 Challenge 18 Solution_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French Download
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,300 --> 00:00:00,580 All right. 2 00:00:00,590 --> 00:00:04,040 So here comes the answer to the challenge. 3 00:00:04,090 --> 00:00:09,580 First things first because Lodash is available to us through NPM, then we're going to install it in 4 00:00:09,580 --> 00:00:15,310 the same way that we've installed Express EJS or Request to any of the previous libraries that we've 5 00:00:15,310 --> 00:00:16,430 worked with. 6 00:00:16,870 --> 00:00:25,120 Firstly we have to Control + C to quit our server and then we're going to run npm i or npm install and then 7 00:00:25,120 --> 00:00:30,260 we're going to spell out lodash and then we'll let that install in the background. 8 00:00:30,270 --> 00:00:36,090 Now the next thing we need to read in the documentation is how to use it using Node.js. And the way 9 00:00:36,090 --> 00:00:44,070 that they prefer you to use the library is to create a new variable using a underscore or what is also 10 00:00:44,070 --> 00:00:46,520 known as a low dash. 11 00:00:46,560 --> 00:00:49,380 That is how some people might refer to that symbol. 12 00:00:49,560 --> 00:00:55,480 Now in modern versions of Javascript we favor constant over var, so we're going to change that. 13 00:00:55,680 --> 00:01:00,490 And then we're going to require lodash so that we tap into all of its capabilities. 14 00:01:00,510 --> 00:01:03,570 Let's go into Atom and do that right at the top. 15 00:01:03,690 --> 00:01:09,480 So we're going to create a new const and it's going to be a underscore or a lodash. And then we'll 16 00:01:09,480 --> 00:01:15,430 get to set that to equal require the package that is lodash. 17 00:01:15,660 --> 00:01:20,020 And now we have access to all of the utilities in this library. 18 00:01:20,100 --> 00:01:26,070 Now as I mentioned, the particular one that we're interested in is the one that turns everything into 19 00:01:26,070 --> 00:01:34,380 a lower case and ignores all of the dashes or the underscores so that we get a clear text that we can 20 00:01:34,380 --> 00:01:41,250 work with and we can compare. In order to use this method they've shown you appear that you simply write 21 00:01:41,330 --> 00:01:47,760 underscore, which refers to the lodash utility library, .and then we specify the name of the method 22 00:01:48,060 --> 00:01:54,270 which is lowercase and then inside some parentheses we specify a string. 23 00:01:54,270 --> 00:01:57,810 Let's go ahead and do that over here. 24 00:01:57,810 --> 00:02:03,600 Now we want to convert our requested title from whatever format it is that the user put in here. 25 00:02:03,630 --> 00:02:10,669 They could have an uppercase, lowercase, kebab case, snake case, whatever it is they decided to use. 26 00:02:10,720 --> 00:02:15,560 We're going to convert it to the same format by using that lowercase method. 27 00:02:15,570 --> 00:02:24,810 So now we're going to say const requestedTitle is equal to underscore or lodash .lowercase and then 28 00:02:24,810 --> 00:02:31,310 we're going to open a set of parentheses and inside here is where we're going to put our string. 29 00:02:31,980 --> 00:02:36,830 Now if you only want to convert a single string then you can simply specify it like this. 30 00:02:36,870 --> 00:02:42,670 But if you have an array of strings then you can also put it into an array like so. 31 00:02:43,640 --> 00:02:45,490 Both methods will work. 32 00:02:45,800 --> 00:02:53,190 So now we have our requestedTitle converted to lowercase, but our storedTitle is still capitalized right? 33 00:02:53,480 --> 00:02:57,700 And so we have to apply the same method to the storedTitle. 34 00:02:57,770 --> 00:03:05,600 So let's do the same down here. _.lowercase open a set of parentheses and include the 35 00:03:05,600 --> 00:03:08,580 thing that we want to convert which is our post.title. 36 00:03:08,900 --> 00:03:16,520 So now if we hit save and we head back into our console and we restart our Node server and then we go 37 00:03:16,520 --> 00:03:24,290 ahead and create a brand new post, just go over to compose let's just call it Another post and then I'm going 38 00:03:24,290 --> 00:03:27,750 to paste in some lorem ipsum, hit publish 39 00:03:27,780 --> 00:03:29,490 and now I have access to that. 40 00:03:29,720 --> 00:03:36,440 And then over here in the URL I'm going to tap into the route that is /posts/ 41 00:03:36,620 --> 00:03:45,410 another-post and the URL is all in lowercase whereas our title is-- has a capitalized another and then 42 00:03:45,410 --> 00:03:47,390 it's got a space and then it's got post. 43 00:03:47,420 --> 00:03:49,600 But I'm going to use kebab case over here 44 00:03:49,610 --> 00:03:52,880 so I have a hyphen between another and post. 45 00:03:53,060 --> 00:04:00,830 And now when I hit enter and I check my console, I still get a match found because we've converted this 46 00:04:00,830 --> 00:04:07,370 title and this part of the parameter both into lowercase, we've thrown away all the hyphens or underscores 47 00:04:07,430 --> 00:04:13,010 and we just have a clear text that both now match. As long as those strings match and they're in the 48 00:04:13,010 --> 00:04:15,750 right order then we will get a match. 49 00:04:15,800 --> 00:04:18,910 And this is going to set us up for the next challenge. 5538

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