Title Case a Sentence

In this example below you will see how to do a Title Case a Sentence with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by -J0hn-, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright -J0hn- ©

Technologies

  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Title Case a Sentence</title>
  
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

  
  
  
</head>

<body>

  
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/-J0hn-/title-case-a-sentence-Gxjaaa */
function titleCase(str) {
  var strArr = str.toLowerCase().split(' ');
  
  
  const newStr =  strArr.map(s =>  {
    return s.slice(0,1).toUpperCase() + s.slice(1)
  }).join(' ')
  console.log(newStr)
  
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");

Comments