File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 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 convertToUpperSnakeCase ( inputString ) {
19+ // Split the string into words using spaces as separators
20+ const words = inputString . split ( ' ' ) ;
21+
22+ // Convert each word to uppercase using map() function
23+ const upperWords = words . map ( word => word . toUpperCase ( ) ) ;
24+
25+ // Join the uppercase words with underscores
26+ const upperSnakeString = upperWords . join ( '_' ) ;
27+
28+ return upperSnakeString ;
29+ }
30+
31+ // Test the function
32+ console . log ( convertToUpperSnakeCase ( "hello there" ) ) ; // HELLO_THERE
33+ console . log ( convertToUpperSnakeCase ( "lord of the rings" ) ) ; // LORD_OF_THE_RINGS
34+ console . log ( convertToUpperSnakeCase ( "UPPER SNAKE CASE" ) ) ; // UPPER_SNAKE_CASE
35+
You can’t perform that action at this time.
0 commit comments