I am newby here and in programming, who started with Python. When I started studying JavaScript, I learned, while doing excercises, that there is no easy way to capitalize first letter of each word in a string.
I found this solution on the web, that allows to do it with vanilla JS:
This code is good for two variables. If there is just one variable containing string 'andrey kudinov', then it would be even more complex task since I don't know index of the second word (users have dffferent name lengths).
Now how I capitalize first letter of each word in Python:
I think that there are many instances where there is a need to address to a user. And it would be very helpful to have this kind of method in vanilla JavaScript to simplify developers' work.
If there is a simple way to do it in JS (similar to Python) aleardy in existence, I would be happy to see it. So far, I have not found anything as simple as in Python.
But, as noted in the thread linked above, this does not work properly for many types of sentences, for example, it won't leave words like "the" in lowercase like a proper title-casing should do. Python's .title() is incorrectly implemented and fails to handle these language nuances as well.
Totally support that idea. It's just written a bit more complex than mine simplified suggestion. I thought it was something different related to advanced level :).
Thanks for the in-depth explanation. But I guess my idea should simply be applied to limited cases, specifically working with usernames, book titles and similar cases where a developer needs to make sure that there is no duplicate in a database records.
Could you expound on these use-cases, I'm not sure I follow. If you want to make sure there's no duplicates in the database, you usually can perform a case-insensitive search.