File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +33
-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 toUpperSnakeCase ( string ) {
19+ //split the string into an array of words
20+ const wordsArray = string . split ( " " ) ;
21+ // Convert each word to uppercase
22+ const upperWordsArray = wordsArray . map ( ( word ) => word . toUpperCase ( ) ) ;
23+ // Join the array back into a string with underscores
24+ const toUpperSnakeCase = upperWordsArray . join ( "_" ) ;
25+ // Return the string in UPPER_SNAKE_CASE
26+ return toUpperSnakeCase ;
27+ }
28+ // Example usage for this function
29+ // let string = "hello there";
30+
31+ // console.log(`The string in UPPER_SNAKE_CASE is: ${toUpperSnakeCase(string)}`);
32+
33+ console . log (
34+ `The string in UPPER_SNAKE_CASE for 'hello there' is: ${ toUpperSnakeCase (
35+ "hello there"
36+ ) } `
37+ ) ;
38+
39+ console . log (
40+ `The string in UPPER_SNAKE_CASE for 'lord of the rings' is: ${ toUpperSnakeCase (
41+ "lord of the rings"
42+ ) } `
43+ ) ;
44+
45+ console . log (
46+ `The string in UPPER_SNAKE_CASE for 'example usage for this function' is: ${ toUpperSnakeCase (
47+ "example usage for this function"
48+ ) } `
49+ ) ;
You can’t perform that action at this time.
0 commit comments