Skip to content

Commit e27fa7b

Browse files
committed
2-cases.js committed
1 parent 3cfeecd commit e27fa7b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Sprint-2/3-mandatory-implement/2-cases.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,22 @@
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+

0 commit comments

Comments
 (0)