Skip to content

Instantly share code, notes, and snippets.

@guumaster
Created October 27, 2015 15:10
Show Gist options
  • Save guumaster/1949343af406129489a8 to your computer and use it in GitHub Desktop.
Save guumaster/1949343af406129489a8 to your computer and use it in GitHub Desktop.
'use strict';
let convert = (str) => {
return str
.trim()
.split(/ +/)
.reduce((acc, word) => {
return (acc + ' ' + word[0].toUpperCase() + word.slice(1).toLowerCase()).trim();
}, '');
}
module.exports = convert;
@IGZmiguelangelmurillo
Copy link

'use strict';

let capitalize = function(str){
let words = str.split(' ');
capitalize = words.reduce(function(prev, actual){
var cap = actual[0].toUpperCase();
return prev + ' ' + cap + actual.slice(1) ;
}, '');
return capitalize.trim();
};

module.exports = capitalize;

@IGZalejandrocuerdo
Copy link

function capitalizeWord(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

module.exports = {capitalizeWord};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment