Skip to content

Commit d4e48c6

Browse files
- add function to convert string to UPPER_SNAKE_CASE
- Chain toUpperCase() and replaceAll() to format spaces as underscores - Add console logs to verify the code is working
1 parent dfdd088 commit d4e48c6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
// When we call this function with the input string
1010
// it returns the string in UPPER_SNAKE_CASE, so "HELLO_THERE"
1111

12+
function upperSnakeCase(str) {
13+
return str.toUpperCase().replaceAll(' ', '_');
14+
}
15+
16+
console.log(upperSnakeCase('hello world')); // Output: HELLO_WORLD
17+
console.log(upperSnakeCase('lord of the rings')); // Output: LORD_OF_THE_RINGS
18+
1219
// Another example: "lord of the rings" should be "LORD_OF_THE_RINGS"
1320

1421
// You will need to come up with an appropriate name for the function

0 commit comments

Comments
 (0)