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+ // MDN References I used:
19+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function
20+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
21+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
22+
23+ function toUpperSnakeCase ( input ) {
24+ return input
25+ // Removes extra spaces
26+ . trim ( )
27+ // Converts everything to caps
28+ . toUpperCase ( )
29+ // Replaces all spaces with underscores
30+ // g means global, so it applies to the whole string
31+ // / / is a regular expression matching a space
32+ . replace ( / / g, "_" ) ;
33+ }
34+
35+ console . log ( toUpperSnakeCase ( "hello there" ) ) ; // HELLO_THERE
You can’t perform that action at this time.
0 commit comments