Function toSentenceCase(str_arg)

I need a function is toSentenceCase(str_arg) – it will be used to force a sentence to have the first word capitalized and the rest in lower case.

Pls, anyone)?

function toSentenceCase(str) {
  return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();
}

edit: ha! Almost the same.


function toSentenceCase(str) {
  return str.substr(0,1).toUpperCase() + str.substr(1).toLowerCase();
}

:slight_smile: