re: Daily Challenge #95 - CamelCase Method VIEW POST

FULL DISCUSSION
 
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

code of conduct - report abuse