Skip to content

Instantly share code, notes, and snippets.

Created December 5, 2015 13:16
Show Gist options
  • Save anonymous/e7d8f8b57abc7349cb75 to your computer and use it in GitHub Desktop.
Save anonymous/e7d8f8b57abc7349cb75 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/bskydive 's solution for Bonfire: Title Case a Sentence
// Bonfire: Title Case a Sentence
// Author: @bskydive
// 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 strToMasUpperCased=str.split(' ').map(
function (val){
val=val.toLowerCase();
var valToMas=val.split('');
valToMas[0]=valToMas[0].toUpperCase();
return valToMas.join('');
}
).join(' ');
return strToMasUpperCased;
}
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