Skip to content

Instantly share code, notes, and snippets.

@IGZalejandrocuerdo
Forked from guumaster/convert.js
Last active October 27, 2015 15:12
Show Gist options
  • Save IGZalejandrocuerdo/aff86ebc5245d9496c1a to your computer and use it in GitHub Desktop.
Save IGZalejandrocuerdo/aff86ebc5245d9496c1a 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;
function capitalizeWord(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment