mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
Add check to handle empty string input.
Could throw an error instead, but to be consistent with other case conversion functions in this collection, it returns an empty string when input is empty string.
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
* @returns {string} A string that is in title case.
|
||||
*/
|
||||
const titleCaseConversion = (inputString) => {
|
||||
if (inputString === '') return ''
|
||||
// Extact all space seprated string.
|
||||
const stringCollections = inputString.split(' ').map(word => {
|
||||
let firstChar = ''
|
||||
|
Reference in New Issue
Block a user