Skip to content

Commit 302855c

Browse files
committed
2-cases.js updated
1 parent 61b4f71 commit 302855c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
// it returns the string in UPPER_SNAKE_CASE, so "HELLO_THERE"
1111

1212
// Another example: "lord of the rings" should be "LORD_OF_THE_RINGS"
13+
function toUpperSnakeCase(str) {
14+
15+
const withUnderscores = str.replace(/ /g, "_");
16+
17+
const upperSnake = withUnderscores.toUpperCase();
18+
19+
return upperSnake;
20+
}
21+
console.log(toUpperSnakeCase("hello there"));
22+
console.log(toUpperSnakeCase("lord of the rings"));
1323

1424
// You will need to come up with an appropriate name for the function
1525
// Use the MDN string documentation to help you find a solution

0 commit comments

Comments
 (0)