Welcome back.
So I told you that I would show you how to use this in a shorter statement.
I'm going to show you real quick.
So instead of saying score equals score plus one, you could have said score plus plus.
But more on that in the next video.
I think what we should focus on right now would be to make sure that it doesn't matter if we are entering
something with an empty space at the beginning or at the end or not.
So let's start with that before we go into lowercase and uppercase.
So the user answer is this string that we get from the user entry.
Right.
And in order to get rid of an empty space at the beginning or at the end, we can use this method called
trim.
So there is this trim which removes all leading and trailing whitespace characters from the current
string, which means all empty spaces at the beginning, as well as at the end of our string of the
user entry, so to speak.
Okay.
And then there is trim end and trim start as well.
So these would be just trim and the trailing ones.
So at the end of the string would be taken away.
So all of the white spaces or um well empty spaces so to speak.
And trim start does that for the beginning.
So for the start of the string.
So I'm going to say I want that to happen for the beginning and the end.
So I'm going to use trim here.
So user answer one dot trim.
So if we run this now and let's say I have a few empty spaces.
And I enter Berlin now and a few empty spaces at the end, it's still going to say correct.
Okay.
So that's what this trim keyword does.
Then if we want to make sure that we are also using upper and lower case, or we are ignoring basically
upper or lower case, we can just set everything to lower.
So there is this other method the string method which is called to lower.
There is another one that is called two upper.
Two upper will do the opposite.
So it makes every single character inside of a string a capitalized character.
It's like you're toggling caps and you're typing everything in caps.
So it's like angry caps, kids basically.
So that's what this two upper would do.
And two lower basically just changes from Berlin uppercase to Berlin lowercase in that case.
So we need to use the brackets again.
So you see how to use methods.
It's similar to what we did with int methods.
So scored int parse for example.
Right.
We could parse something by using int dot and then the method name.
And in this case we're using the string variable itself dot method name brackets by by using the brackets
we're basically executing that method.
And then we can apply another method on top of that as well.
So here another dot to lower.
So what this will do this statement here it will trim the white spaces at the beginning and at the end.
And at the same time it will make the whole text lowercase.
And now we need to do the same thing for the answer.
So dot two lower as well here.
And then we need to add the bracket the yeah the brackets here as well.
So what this will do is it will not matter if we are entering Berlin.
Let me show you again Berlin with an empty space like this or whether we're entering entering it exactly
like it's written here.
So that's what this trim to lower does.
So now let's do the same thing for our other answers as well.
So I'm just going to copy that.
Keep it simple.
So here and then I'm replacing answer one with answer two for all of those.
And the same goes for this one here.
So I'm replacing answer one with answer three in that case.
So now it won't matter if we're using lowercase or uppercase empty spaces.
Whatever.
All is good.
We just need to make sure that we enter the name correctly.
So what color do you want to use?
Let's say green like this.
And you see we have everything correctly okay.
So that's a little bit of something that you can apply towards strings.
There are a lot more methods that strings offer to us.
So if you go and say on user answer dot you see there are plenty more okay.
A lot of different methods.
Some have these greater sign small lower signs to them.
But that's a little something for later okay.
So that's pretty much it for this video.
See you in the next one.