Skip to content

Instantly share code, notes, and snippets.

@Zielak
Created October 30, 2018 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zielak/88018b992f1638c2f5be0e71c2607241 to your computer and use it in GitHub Desktop.
Save Zielak/88018b992f1638c2f5be0e71c2607241 to your computer and use it in GitHub Desktop.
but string doesn't have `map` method... hold my beer
String.prototype.map = function(predicate) {
const arr = []
for (var i = 0; i < this.length; i++) {
arr.push(predicate(this.charAt(i), i))
}
return arr.join('')
}
// ᕕ( ᐛ )ᕗ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment