Updated the writing exam to work based on exercises instead of just a single one
This commit is contained in:
9
src/utils/string.ts
Normal file
9
src/utils/string.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
function convertCamelCaseToReadable(camelCaseString: string): string {
|
||||
// Split the string using regex to match the capital letters
|
||||
const wordsArray = camelCaseString.split(/(?=[A-Z])/);
|
||||
|
||||
// Capitalize the first letter of each word and join the words with a space
|
||||
const readableString = wordsArray.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
||||
|
||||
return readableString;
|
||||
}
|
||||
Reference in New Issue
Block a user