Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Let's continue with some simple string methods.
And the first two are gonna be
for changing the case of a string.
So that's airline.to lowercase.
And this doesn't require any arguments at all.
And then we also have to uppercase.
And these we use all the time,
as you will see soon in a more real world example.
And here you see that indeed, they transform to string,
all to lowercase, and to uppercase.
And again, you can of course, call these directly,
also on a string, so like this, all right?
But now let's use this on a more practical example,
to fix the capitalization in a passenger name.
capitalization in name, okay?
So let's say that the passenger when he checked in
I misspelled his name, and so it looks like this now.
And so this needs to be fixed,
it should look like this, okay?
So in order to fix it, the first step is usually
to put everything into lowercase here.
So const, passenger, lower
is passenger.to lowercase, like this.
Okay, so basically, we already have now this part here.
And now all we need to do is to essentially
take the first letter, and then the rest of the string
and put these two parts back together.
So passenger, correct, will be passenger lowercase.
And here, we only need the first letter.
So how do we do that,
we take the first letter by using the index zero.
And so this one, we now convert to uppercase, all right?
And now we simply need to add the rest of the string.
So, again, we take passenger lower,
and then we use the slice that we learned
in the last lecture, and start at position number one,
because remember, that will then go to index one,
and take everything until the end of the string.
And so here, we then put back together,
just the first part of the string
converted to uppercase here, and then the rest of the string
that we already had converted to lowercase before.
Now, okay, and, indeed, now it is corrected, great.
And of course, we could have done a function with this.
And so maybe if you have the time, you can do that.
So just create a function which takes any passenger name,
and then returns the correct one.
So with the fixed capitalization, but anyway,
I will now do another real life example,
which is to check a user input email, okay?
So check email, now, this will not be really a checking,
it will more be a comparing, so comparing emails.
So let's say that we have to email of one passenger.
So hello at Jonas.io, but now as the user logs in,
so let's say login email, accidentally they do it all wrong,
and they start with a couple of spaces here,
and then the capitalization is all completely off
like this, and then maybe even another space,
or even an enter character, which remember is backslash n.
So I think we talked about that in the beginning, okay?
But still, this email here is actually still kind of correct
and kind of valid.
And so we can now still compare
if these two are kind of the same, okay?
So we can now try to convert this one to this one,
and then check if they are the same.
Because essentially, again, they are,
they would be different if we had
like different letters here, then of course,
they would not be the same.
But here it's just a matter of capitalization.
And for emails I believe that they are still valid
even with the capitalization off.
And so when we check user input like this,
the first step is usually to convert it to lowercase.
So lower email, is login email.to lowercase.
And then we must also get rid of all the whitespace here.
So these empty spaces, and also this enter basically here
also counts as a whitespace.
So there is even a method for that.
So let's say, trimmed email.
And so that is lower email.trim.
All right, let's just now log this to the console
just to see.
And so that looks exactly like that first version.
Now, just look closely at what we did here.
So we called to lowercase on this login email,
stored it to this variable,
and then on that variable, we called the trim method.
But why do we even need this intermediate email?
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.