Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2015 01:21
Show Gist options
  • Save anonymous/07316b3eb0ad445779eb to your computer and use it in GitHub Desktop.
Save anonymous/07316b3eb0ad445779eb to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/fcc0208647c 's solution for Bonfire: Title Case a Sentence
// Bonfire: Title Case a Sentence
// Author: @fcc0208647c
// Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function titleCase(str) {
arr = str.toLowerCase().split(' ');
console.log(arr);
uppers = arr.map(upperWord);
propercase = uppers.join(' ');
return propercase;
function upperWord(word) {
word = word.split('');
letter = word[0].toUpperCase(); // get final and concat
final = letter + word.slice(1,word.len).join('');
return final;
}
}
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