Is there a simple way to convert a string to title case? E.g. john smith
becomes John Smith
. I\'m not looking for something complicated like John R
Simple way to convert an individual word to title case
Using the "Slice" method and String concatenation
str.slice(0, 1).toUpperCase() + str.slice(1, str.length)
*Add .toLowerCase() to the end if you want to lowercase the rest of the word
Using ES6 Spread Operator, Map, and Join
[...str].map((w, i) => i === 0 ? w[0].toUpperCase() : w).join('')