function CamelCase(s) { var uppercase = true; var rv = ''; for (var i = 0; i < s.length; ++i) { var c = s[i]; if (c == ' ') { uppercase = true; continue; } if (uppercase) { rv += c.toUpperCase(); uppercase = false; } else { rv += c; } } return rv; }
And benchmarked:
(Chrome 77, Win 10, 100K runs):
86 ms for LaBlatte 79 ms for SavagePixie 56 ms for Asfo 55 ms for BlessedTMahuni 54 ms for HVHarish 30 ms for Anders
(Firefox 69, Win 10, 100K runs):
116 ms for LaBlatte 55 ms for HVHarish 53 ms for Asfo 51 ms for BlessedTMahuni 29 ms for SavagePixie 23 ms for Anders
(Edge, Win 10, 100K runs):
208 ms for LaBlatte 127 ms for HVHarish 91 ms for Asfo 77 ms for BlessedTMahuni 46 ms for SavagePixie 27 ms for Anders
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
And benchmarked:
(Chrome 77, Win 10, 100K runs):
86 ms for LaBlatte
79 ms for SavagePixie
56 ms for Asfo
55 ms for BlessedTMahuni
54 ms for HVHarish
30 ms for Anders
(Firefox 69, Win 10, 100K runs):
116 ms for LaBlatte
55 ms for HVHarish
53 ms for Asfo
51 ms for BlessedTMahuni
29 ms for SavagePixie
23 ms for Anders
(Edge, Win 10, 100K runs):
208 ms for LaBlatte
127 ms for HVHarish
91 ms for Asfo
77 ms for BlessedTMahuni
46 ms for SavagePixie
27 ms for Anders