(str: string, withPeriod = true)
| 103 | * Capitalizes a string by capitalizing the first letter and optionally appending a period. |
| 104 | */ |
| 105 | export function capitalizeSentence(str: string, withPeriod = true) { |
| 106 | let newStr = str.charAt(0).toUpperCase() + str.slice(1); |
| 107 | if (withPeriod && str.charAt(str.length - 1) !== ".") { |
| 108 | newStr += "."; |
| 109 | } |
| 110 | |
| 111 | return newStr; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * e.g. "some-example-string" returns a "Some example string". |
no outgoing calls
no test coverage detected