Skip to content

Instantly share code, notes, and snippets.

@brianswisher
Last active December 29, 2015 16:36
Show Gist options
  • Save brianswisher/f1cb12fdd2ba789bbcf0 to your computer and use it in GitHub Desktop.
Save brianswisher/f1cb12fdd2ba789bbcf0 to your computer and use it in GitHub Desktop.
Capitalize Utililty
var util = require("./util.js");
console.log(util.capitalize("hello"));
!function(name){
if (typeof exports === "undefined"){
if (!this[name]) this[name] = {}
this.exports = this[name];
}
}("util")
exports.capitalize = function(str){
/* assumption: can use ES6 template strings */
return `${str.charAt(0).toUpperCase()}${str.slice(1)}`
};
@brianswisher
Copy link
Author

util.js is isomorphic.

<script src="util.js"></script>
<script>
  console.log(util.capitalize("hello"));
</script>

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