Skip to content

Commit 11a298c

Browse files
committed
Answering the task 2 cases
1 parent 336d1b4 commit 11a298c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
// A set of words can be grouped together in different cases.
23

34
// For example, "hello there" in snake case would be written "hello_there"
@@ -14,3 +15,15 @@
1415
// You will need to come up with an appropriate name for the function
1516
// Use the MDN string documentation to help you find a solution
1617
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
18+
19+
function capSnakeCase(str) {
20+
const upper = str.toUpperCase();
21+
const snake = upper.replace(/ /g, "_");
22+
return snake;
23+
}
24+
console.log(capSnakeCase("lord of the rings"));
25+
26+
// step 1: get a string input
27+
//step 2: change the upper case
28+
//step 3: replace spaces with underscores
29+
// step 4: return capSnakeCase

0 commit comments

Comments
 (0)