There are many reasons as to why someone would need to use it. One example would be if someone has a search bar on their website. Since user input is unpredictable, we need to make sure we are handling the user input in the best way possible. We should convert the strings into one case which is why we were making it all lowercase. Doing that will ensure that the results will match the search.
Let’s look at how .toLowerCase() works!
First, lets declare a string with the name of stringOne:
const stringOne = “Let’s see HOW .toLowerCase() Works”
Then, we will use the syntax for .toLowerCase() on this string:
Finally, we can console.log the string with and without the new syntax to see the difference:
Now, let's see what the console.log shows us:
Let’s see HOW .toLowerCase() Works let’s see how .tolowercase() works
If we did not have this method, we would have to manually parse the string using regular expressions. That would take a really long time!