Skip to content

Commit 6b8a9de

Browse files
committed
Implement toUpperSnakeCase function to convert strings to UPPER_SNAKE_CASE
1 parent ed8e968 commit 6b8a9de

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@
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+
function toUpperSnakeCase(inputString) {
19+
// Split the input string into words using space as the delimiter
20+
const words = inputString.split(' ');
21+
22+
// Join the words with underscores and convert to uppercase
23+
const upperSnakeCaseString = words.join('_').toUpperCase();
24+
25+
return upperSnakeCaseString;
26+
}
27+
28+
29+
console.log(toUpperSnakeCase("hello there")); // Output: "HELLO_THERE"
30+
console.log(toUpperSnakeCase("lord of the rings")); // Output: "LORD_OF_THE_RINGS"

0 commit comments

Comments
 (0)