File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1111
1212// Another example: "lord of the rings" should be "LORD_OF_THE_RINGS"
1313
14+ function toUpperSnakeCase ( input ) {
15+ return input . toUpperCase ( ) . replace ( / / g, "_" ) ;
16+ }
17+
18+ console . log ( toUpperSnakeCase ( "hello there" ) ) ; // "HELLO_THERE"
19+ console . log ( toUpperSnakeCase ( "lord of the rings" ) ) ; // "LORD_OF_THE_RINGS"
20+ // in the above code, we are using the toUpperCase method to convert the string to uppercase
21+ // and then using the replace method to replace spaces with underscores.
22+ // This is a simple implementation of the function to convert a string to UPPER_SNAKE_CASE.
23+ // here replace(/ /g, "_") is used to replace all spaces in the string with underscores.
24+
1425// You will need to come up with an appropriate name for the function
1526// Use the MDN string documentation to help you find a solution
1627// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
You can’t perform that action at this time.
0 commit comments