DEV Community

Discussion on: Capitalize first letter in every sentence?

Collapse
 
alibasiccoder profile image
AliBasicCoder • Edited

i think you should use slice instead of substr

function toUpper(str) {
   return str
            .toLower()
            .spilt(" ")
            .map(word => word[0] + word.slice(1))
            .join("")
}