Solution for CamelCase

pull/2/head
Raphael 2019-09-22 19:25:00 +02:00 committed by GitHub
parent 3946ff26a4
commit 1cadad130e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
String.prototype.camelCase = function() {
return this
.split(' ')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join('');
}
Test.describe("Basic tests", _ => {
Test.assertEquals("test case".camelCase(), "TestCase");
Test.assertEquals("camel case method".camelCase(), "CamelCaseMethod");
Test.assertEquals("say hello ".camelCase(), "SayHello");
Test.assertEquals(" camel case word".camelCase(), "CamelCaseWord");
Test.assertEquals("".camelCase(), "");
});