Skip to content

Instantly share code, notes, and snippets.

@jacopotarantino
Last active November 10, 2015 16:17
Show Gist options
  • Save jacopotarantino/f3796eaa55f594c96460 to your computer and use it in GitHub Desktop.
Save jacopotarantino/f3796eaa55f594c96460 to your computer and use it in GitHub Desktop.
js notes
  • check out feross/standard for some javascript style advice and a plugin to autocorrect violations
  • never be afraid to write variables with long fuckall names. readability is more important than shorthand
  • always wrap code in an IIFE to prevent global namespace pollution
  • good job on the wordSubstituter method
  • bulkShortener: i'd prefer a map/forEach to a for loop
  • if this were in my codebase i'd make you write inline documentation but that's fine here
  • triple extra bonus points if you rewrote this in a more class-based manner like:
class Tweet {
  constructor(tweet_text) {
    this.tweet_text = tweet_text
  }

  shorten() {
    this.tweet_text = this.tweet_text.substr(0, 137)
    return this
  }

  regex() {
    // run some regex...
    return this
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment