changetotitlecase
Advanced tools
Comparing version 1.0.0 to 2.0.0
18
index.js
"use strict" | ||
let titleCase = (str)=>{ | ||
let titleCase = (str, restToLowerCase=false)=>{ | ||
let strArray =str.split( " "); | ||
let retStr = ""; | ||
if(restToLowerCase === true){ | ||
strArray.forEach(word=>{ | ||
if(word !== ""){ | ||
let concatWord = `${word.charAt(0).toUpperCase()}${word.substr(1).toLowerCase()} ` | ||
retStr= retStr.concat(concatWord); | ||
} | ||
}) | ||
}else{ | ||
strArray.forEach(word=>{ | ||
if(word !== ""){ | ||
let concatWord = `${word.charAt(0).toUpperCase()}${word.substr(1).toLowerCase()} ` | ||
let concatWord = `${word.charAt(0).toUpperCase()}${word.substr(1)} ` | ||
retStr= retStr.concat(concatWord); | ||
@@ -14,2 +25,5 @@ | ||
}) | ||
} | ||
@@ -16,0 +30,0 @@ return retStr.trim(); |
{ | ||
"name": "changetotitlecase", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Coverts the string to title case for ex:- I am good\" it converst to I Am Good", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,4 @@ | ||
# changetotitlecase | ||
# titlecase | ||
This javascript node module for conversion of string in to title case | ||
For example :- 'i am good looking' to 'I Am Good Looking' |
1686
4
23