Created
December 7, 2015 06:17
-
-
Save anonymous/af231d15fb54475d1eef to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/kkas 's solution for Bonfire: Title Case a Sentence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bonfire: Title Case a Sentence | |
// Author: @kkas | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence# | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function titleCase(str) { | |
var newStrAry = str.split(' ').map(function(word) { | |
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); | |
}); | |
return newStrAry.join(' '); | |
} | |
titleCase("I'm a little tea pot"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment