forked from WildCodeSchool/js-katas
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pascal-case.js
37 lines (29 loc) · 887 Bytes
/
pascal-case.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Create a function `pascalCase` which convert a sentence into upper case Camel Case, also known as Pascal Case.
Example:
* "this is sparta" > "ThisIsSparta"
* "sO rAdicAL DuDe" > "SoRadicalDude"
You can't use a loop!
Don't mutate the parameter.
*/
// TODO add your code here
// Begin of tests
const assert = require("assert");
assert.strictEqual(typeof pascalCase, "function");
assert.strictEqual(pascalCase.length, 1);
assert.strictEqual(
pascalCase.toString().includes("for "),
false,
"don't use a loop"
);
assert.strictEqual(
pascalCase.toString().includes("while "),
false,
"don't use a loop"
);
assert.strictEqual(pascalCase("this is sparta"), "ThisIsSparta");
assert.strictEqual(pascalCase("sO rAdicAL DuDe"), "SoRadicalDude");
let test = "no mutation";
pascalCase(test);
assert.strictEqual(test, "no mutation", "don't mutate the parameter");
// End of tests