File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change 1- // A set of words can be grouped together in different cases.
1+ // This function converts any sentence into UPPER_SNAKE_CASE
2+ function toUpperSnakeCase ( input ) {
3+ // Step 1: Convert the string to uppercase
4+ const upperCase = input . toUpperCase ( ) ;
25
3- // For example, "hello there" in snake case would be written "hello_there"
4- // UPPER_SNAKE_CASE means taking a string and writing it in all caps with underscores instead of spaces.
6+ // Step 2: Replace all spaces with underscores
7+ const snakeCase = upperCase . replace ( / / g , "_" ) ;
58
6- // Implement a function that:
9+ // Step 3: Return the result
10+ return snakeCase ;
11+ }
712
8- // Given a string input like "hello there"
9- // When we call this function with the input string
10- // it returns the string in UPPER_SNAKE_CASE, so "HELLO_THERE"
11-
12- // Another example: "lord of the rings" should be "LORD_OF_THE_RINGS"
13-
14- // You will need to come up with an appropriate name for the function
15- // Use the MDN string documentation to help you find a solution
16- // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
13+ // Example usage:
14+ console . log ( toUpperSnakeCase ( "hello there" ) ) ; // Output: "HELLO_THERE"
15+ console . log ( toUpperSnakeCase ( "lord of the rings" ) ) ; // Output: "LORD_OF_THE_RINGS"
You can’t perform that action at this time.
0 commit comments