Created
September 23, 2016 19:17
-
-
Save gabrielseco/fe50fb23fe26e2a333fae876fb21e703 to your computer and use it in GitHub Desktop.
Random capitalization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
INSPIRED BY JOHN GREEN'S BOOK PAPER TOWNS | |
DEMO: http://codepen.io/GGarciaSeco/pen/mAWAyk | |
*/ | |
String.prototype.capitalize = function(){ | |
return Math.round(Math.random()) === 1 ? this.charAt(0).toUpperCase() + this.slice(1) + " ": this; | |
} | |
function randomCapitalization(phrase){ | |
return phrase.split(" ") | |
.map(word => word.capitalize()) | |
.join(" "); | |
} | |
const test = `3 whole catfish, wrapped separately | |
veet (it's for shaving your legs only you don't need a razor) | |
it's with all the girly cosmetic stuff | |
vaseline | |
six-pack, mountain dew | |
one dozen tulips | |
one bottle of water | |
tissues | |
one can of blue spray paint | |
`; | |
document.body.innerText = randomCapitalization(test); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment