Skip to content

Commit d8d8f84

Browse files
committed
function created for touppersnakecase
1 parent 4fa6e04 commit d8d8f84

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@
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+
const input1 = "hello there";
19+
const input2 = "lord of the rings";
20+
21+
function toUpperSnakeCase(str) {
22+
// return the string in UPPER_SNAKE_CASE
23+
return str.replace(/ /g, "_").toUpperCase(); // Replace spaces with underscores and convert to uppercase
24+
}
25+
26+
console.log(toUpperSnakeCase(input1)); // should return "HELLO_THERE"
27+
console.log(toUpperSnakeCase(input2)); // should return "LORD_OF_THE_RINGS"

0 commit comments

Comments
 (0)