Skip to content

Commit 3d61c7f

Browse files
committed
In-3-Mandatory-implement/2-cases.js, a code that returns capSnakecase has been writtent and implemented
1 parent 3ba023b commit 3d61c7f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sprint-2/3-mandatory-implement/2-cases.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,19 @@
1414
// You will need to come up with an appropriate name for the function
1515
// Use the MDN string documentation to help you find a solution
1616
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
17+
18+
19+
function capSnakeCase(str) {
20+
21+
const upper = str.toUpperCase();
22+
const snake = upper.replace(/ /g, "_");
23+
24+
return snake;
25+
}
26+
27+
console.log(capSnakeCase("lord of the rings"));
28+
29+
// Step-1 ----> Get a string
30+
// Step-2 ----> change to upper case
31+
// Step-3 ----> Replace space with underscore
32+
// Step-4 ----> Return capSnakeCase

0 commit comments

Comments
 (0)