Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrjames83/6efd24f0427eb455f78d to your computer and use it in GitHub Desktop.
Save jrjames83/6efd24f0427eb455f78d 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