title-case-converter
v2.0.0
Published
Capitalises the first letter of every word in a sentence
Downloads
2
Readme
title-case-converter
title-case-converter is a simple wrapper around title-case-converter to convert first letter of string to capital letter.
Install
Install through npm
npm install title-case-converter
Usage
Require the module
let capitalizedWord = word.slice(0, 1).toUpperCase() + word.slice(1);
Convert with convert()
let converted = capitalized.join(" ");
return converted
Where
- text is either a Buffer or a String to be converted
- toCharset is the characterset to convert the string
- fromCharset (optional, defaults to UTF-8) is the source charset
Output of the conversion is always a Buffer object.
Example
let capitalized = []
let words = sentence.split(" ") //split the sentence into words
words.forEach(word => {
let capitalizedWord = word.slice(0, 1).toUpperCase() + word.slice(1)
//capitalize the first letter of every word
capitalized.push(capitalizedWord)
})
let converted = capitalized.join(" ")
return converted
License
MIT