re: Capitalize the first letter of every word VIEW POST

re: I added your function to the benchmark site linked by @aminnairi Benchmark hello world Regex seems to performance the fastest... mostly. I'm not ...

Hey thanks for that, that's awesome!

One nice thing about the regex way is that it targets the letters it needs to capitalize. I added test cases for an already capitalized sentence and toTitleCase gets a 400% speedup compared to the non-capitalized sentence (since it won't call toUpperCase if it doesn't need to). The others didn't get any speed up (their code could be tweaked, but I don't think there's a way to get such a boost).
Benchmark here

Code of Conduct Report abuse