Solution for CamelCase
parent
3946ff26a4
commit
1cadad130e
|
@ -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(), "");
|
||||
});
|
Loading…
Reference in New Issue